← Design Patterns learning pathDesign Patterns · Module 7 of 10
Command, State and Template Method
More behavioural patterns.
📖 Key ideas
- Command wraps a request as an object: supports undo, queues, logging.
- State changes an object's behaviour when its state changes (order: placed → shipped → delivered).
- Template Method defines an algorithm skeleton; subclasses fill steps.
- Iterator gives sequential access without exposing structure.
- Chain of Responsibility passes a request along handlers.
💡 Real-life example: Template Method is a fill-in-the-blanks exam paper: structure fixed, answers vary by student.
CommandRequest as an object
StateBehaviour changes with state
Template MethodAlgorithm skeleton with overridable steps
Chain of ResponsibilityRequest passed along handlers