Join Jungwoo Ryoo for an in-depth discussion in this video State example, part of Python: Advanced Design Patterns.
- [Instructor] Implementing the state design pattern,…starts with defining a base state class.…In our example we model different states…of an automatic teller machine in the base class.…This is why we name our class,…ATM class as you can see here.…The AtmState has two attributes,…the name attribute stores a string indicating…the state it's concrete state class represents.…
For example the name attribute contains the string off…indicating the off state, which the off concrete state class…represents as you can see here.…The allowed variable is a list holding…information on the possible next state associated…with the current state each concrete state class embodies.…
For instance, the off class,…the one you see here,…can only have one choice…in terms of it's next possible state, which is on.…Of course we can accommodate more allowed states…such as out of money, out of order, etc.,…but for the brevity of this example…we'll limit our possible states to only on and off.…
As an exercise let's specify our concrete class for…
- 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
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.