Behavioral patterns
Template Method
A base class fixes the skeleton of an algorithm and subclasses fill in selected steps.
Article
Template Method: a fixed recipe, interchangeable ingredients
The Template Method pattern through importing supplier price lists: the base class fixes the order of steps, and subclasses provide parsing and optional hooks. The Hollywood principle, an inheritance-free variant in Go and code in five languages.
Related articles
- Factory Method – let the subclass decide what gets created
Factory Method separates the algorithm that uses an object from the decision about which exact object is created. A ticket booking example in C#, TypeScript, Java, Go and Python.
Around the topic
- Metoda szablonowa / Template Method article · web · Refactoring.Guru
- Head First design patterns book · openlibrary · Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates
- Design Patterns: Elements of Reusable Object-Oriented Software book · openlibrary · Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson
- Design Pattern Catalog article · web · Java Design Patterns
- Template Method article · web · Refactoring.Guru