Join Jungwoo Ryoo for an in-depth discussion in this video Template method example, part of Python: Advanced Design Patterns.
- [Instructor] Python 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 overwritten by a subclass.…To use this handy python feature,…lets import abstract based classes or, in short, ABC.…So let's type, from ABC import ABC comma abstract method.…
Next, let's define our classes.…The first one, to work on, is our abstract class,…where we define a template method,…as you saw in the UML class diagram…for the template method pattern.…So the abstract class is this one.…In the template method, we'll call four methods…as part of an algorithm.…A couple of operations of which,…will be defined by concrete classes.…
For the template method is defined here.…The first method is a protective method…that should never be overwritten.…It is always called, by default.…So simply type, self dot two underscores,…always do this, parenthesis, note that,…we're using two underscores for the method name.…
This is a python's way of designating this method…
- 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.