Join Jungwoo Ryoo for an in-depth discussion in this video Abstract factory, part of Python: Design Patterns.
- Abstract Factory is especially useful when a client expects to receive a family of related objects at a given time, but don't have to know which family it is until run time. Here is the scenario we'll be using. We'll first build a pet factory whose concrete factories include Dog factory and Cat factory. Both dog and cat factories produce related products such as dog food and cat food.
At least in theory our solution, Abstract Factory, consists of Abstract factory, Concrete factory, Abstract product, and Concrete product. For the Abstract factory we use pet factory in our example. For concrete factory we use dog factory and cat factory in our example. And finally for the concrete product we'll be creating the dog, which is a pet, and the dog food, and also cat and the cat food.
We implement our Abstract Factory without using inheritance, mainly because Python is a dynamically typed language and therefore does not require abstract classes. Abstract Factory is related to factory method and the concrete factories are often singletons.
- 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
Q: In the strategy pattern example, why does the code keep executing the default function rather than the alternate?
A: The programming demonstration skips the step of defining what the strategy pattern should be when an alternate function name is provided
as an argument as shown below.
Programming Foundations: 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.