Join Jungwoo Ryoo for an in-depth discussion in this video Proxy example, part of Python: Design Patterns.
- Let's first define this Producer class,…which is supposed to be more resource intensive…when we're trying to instantiate it.…So the Producer class simply…print some of these messages.…There are two methods defined.…The first one is printing the current status…of the Producer stating…('Producer is working hard!')…and then the second method is simply…printing a statement saying that Producer…has time to now meet a guest.…
So the goal here is not to bother the Producer…until the Producer is available because…the Producer is very expensive to instantiate.…Next, let's define the Proxy class.…The Proxy class is supposed to be…relatively less resource intensive, especially…when we're trying to instantiate it.…And that's why we try to use…this Proxy object as a middle man,…so that we simply handle the request…for the Producer until the Producer…becomes available, and we can afford to…do it because the Proxy class,…the instantiated version of the Proxy class,…or the object of the Proxy class…is much less to create.…
So let's see what happens in the Proxy class.…
- 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.