Join Jungwoo Ryoo for an in-depth discussion in this video Interpreter example, part of Python: Advanced Design Patterns.
- [Instructor] Pattern three has a built in feature…that allows us to designate a certain method…as an abstract method.…When a method is decorated as an abstract method…it should be overridden by a subclass.…To use this handy Python feature, let's import…abstract base classes, or in short, abc.…Type from abc import ABC, abstractmethod…The interpreter pattern needs an abstract…expression class which is our abstract class…that should contain an abstract method called interpret.…
We decorate this method with at abstract method…to force it to be overridden.…So type @abstractmethod def interpret(self): pass…Now let's define our non-terminal expression class…which inherits from the abstract expression class.…
So here is the nonterminal expression class,…inheriting from abstract expression class.…The constructor here stores an expression…when a non-terminal expression object is created.…So type self._expression = expression…The class also implements the interpret method.…
So the interpret method is here.…The interpret method invokes the interpret…
- 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.