Рет қаралды 8,010
►Software Design and Design Patterns Playlist: • C++ Software Design an...
►Find full courses on: courses.mshah.io/
►Join as Member to Support the channel: / @mikeshah
►Git Repo: github.com/MikeShah/DesignPat...
►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
►KZbin Channel: / mikeshah
►Please like and subscribe to help the channel!
►Join our free community: courses.mshah.io/communities/...