Join Jungwoo Ryoo for an in-depth discussion in this video Command example, part of Python: Advanced Design Patterns.
- [Instructor] Let's start by defining our command class,…which has an abstract method called execute.…Def, the name of the method,…execute,…self.…Note that the only method the command class has…is the execute method that serves as an interface…used to execute various self contained operations.…
It doesn't do anything by itself.…Next, let's define some concrete command classes.…The first one is copy.…This class wraps a copy operation.…So type, def, execute, self, print,…the message, copying.…We have two other concrete command classes,…paste and save.…
All these concrete classes do is printing messages…showing what they're doing.…For example, the copy, concrete class, prints a message…showing that it is copying.…Now, we're ready to create our invoker class.…The invoker class creates multiple concrete command objects…and stores them in a list.…We call this invoker class, Macro, right here,…because it simulates how a macro works,…in a word processor.…
That is it stores a sequence of actions to be taken,…in a single container, so that a user doesn't have…
- Architectural vs. design patterns
- Why use design patterns?
- Design best practices
- Domain-specific patterns and security patterns
- Gang of Four design patterns
- Command, Mediator, and State
- Template method
Skill Level Advanced
Learning Python and Django (2015)with Caleb Smith1h 11m Intermediate
Programming Foundations: Design Patternswith Elisabeth Robson2h 19m Intermediate
1. Understanding Design Patterns: Review
2. Design Best Practices
3. Gang of Four (GoF) Patterns, Part 1
4. Gang of Four (GoF) Patterns, Part 2
Next steps1m 26s
- 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.