►Software Design and Design Patterns Playlist: https://www.youtube.com/playlist?list=PLvv0ScY6vfd9wBflF0f6ynlDQuaeKYzyc ►Find full courses on: https://courses.mshah.io/ ►Join as Member to Support the channel: https://www.youtube.com/channel/UCA64pZbN5Mz5NxC3SO4qpDg/join ►Git Repo: https://github.com/MikeShah/DesignPatterns ►Lesson Description: In this lesson I teach you about a creational design pattern to have a single point in which you allocate objects at run-time. This is the factory method (or factory function), which takes advantage of inheritance based polymorphism to create the correct object at run-time and return it to the user. 00:00 Factory method and definition 1:25 Goal of the factory method pattern 2:37 Inheritance based polymorphism 3:40 Start of implementation with interface 4:50 Creating derived classes 5:58 Creation of our factory 9:15 Confirming the factory works in GDB 10:50 Refactoring our factory arguments with enum class 14:35 Returning a smart pointer from our factory 16:12 Confirming no memory leaks with valgrind 17:30 Recap of source code and pattern 18:00 Pros and cons of the pattern ►YouTube Channel: https://www.youtube.com/c/MikeShah ►Please like and subscribe to help the channel! ►Join our free community: https://courses.mshah.io/communities/Q29tbXVuaXR5LTI3MzAz