Join Jungwoo Ryoo for an in-depth discussion in this video Abstract factory example, part of Design Patterns with Python.
- View Offline
- Exercise Files
- We'll start with the object…that will be returned by our concrete factory,…in this case, the dog object.…We need to define the dog class to be used…to instantiate the dog object.…So the usual method where we return woof as a string.…Next is the dog factory,…and this is our concrete factory.…And the concrete factory returns two objects.…
In this case, the first object we're returning is the dog…object, and the second object we're returning…is the dog food object, which is simply, a string object.…So let's complete this code by typing…return, the name of the class, dog,…and then we'll be returning the dog food string object,…so return, dog food.…The next class is the pet store class,…which will be housing our abstract factory,…actually, an instance of our abstract factory.…
So we'll have to have this attribute of the pet store…which is called _pet_factory,…which will be also storing an instance…of this concrete factory class.…The concrete factory class we're talking about in this case,…is dog factory, so let's initialize our attribute…
- Understanding design patterns
- Best design practices: consistency, completeness, and correctness
- Working with creational patterns
- Working with structural patterns
- Working with behavioral patterns
Skill Level Intermediate
Foundations of Programming: Design Patternswith Elisabeth Robson2h 19m Intermediate
1. Understanding Design Patterns
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
5. Design Best Practices
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.