Join Jungwoo Ryoo for an in-depth discussion in this video Prototype example, part of Design Patterns with Python.
- View Offline
- Exercise Files
- The prototype class has…four different methods,…and we'll start with the init method.…In the init method, all we're doing is…simply creating this dictionary object.…The dictionary object will be containing…the objects that will be cloned.…So let's create the dictionary object by typing…self._objects,…and then the second method is register object.…
So, in this method,…we'll be registering the object to be cloned.…So this method takes two arguments.…The first one is name,…and then the second one is the object to be cloned.…The name, in particular, is going to be used as a key…when it comes to storing the object…in the dictionary object.…So, let's simply store the object…we're receiving as argument…into the dictionary object.…
So, type self_objects.…This is our dictionary.…And then the key will be name,…and, using the key,…we'll be storing the object to be cloned.…Next is the unregister object method.…In this method, we'll be deleting the objects…from the dictionary object.…So, simply delete by using dl, and then…self_object,…
- 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.