Join Jungwoo Ryoo for an in-depth discussion in this video Builder example, part of Python: Design Patterns.
- In this exercise, the goal is to build a car object…and to print the details of the car object.…We'll do so by using the various participants…of the builder pattern including…Director, Abstract Builder,…Concrete Builder and object being built.…The Abstract Builder class called…Builder here…creates a car object and keeps it as its attribute…as you can see here.…
The Concrete Builder class called SkyLarkBuilder…that inherits from the Abstract Builder class…but provides methods to be used…by the Director class eventually.…Let's add one more method in the Concrete Builder class…which is the add_engine method.…So d-e-f…add_engine,…we still need self and define it as…self.car.engine…and we set it as Turbo engine.…
Now, the next part is to…go back to the Director class…and then complete the definition of…construct_car method here.…The Director is the one that's actually building the car.…First of all,…you need to create a new car object to get started.…So type self._builder,…so this is actually where the…Concrete Builder object is stored,…
- 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?
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.