Template Method
E173621
Template Method is a behavioral design pattern that defines the skeleton of an algorithm in a base class while allowing subclasses to override specific steps without changing the algorithm’s overall structure.
All labels observed (2)
| Label | Occurrences |
|---|---|
| Template Method pattern | 2 |
| Template Method canonical | 1 |
Statements (46)
| Predicate | Object |
|---|---|
| instanceOf |
behavioral design pattern
ⓘ
software design pattern ⓘ |
| allows | subclasses to override specific steps of an algorithm ⓘ |
| alsoKnownAs | template pattern ⓘ |
| appliesTo | object-oriented programming ⓘ |
| belongsTo |
Gang of Four design pattern
ⓘ
surface form:
Gang of Four design patterns
|
| canBeImplementedIn |
C# programming language
ⓘ
surface form:
C#
C++ ⓘ Java ⓘ Python ⓘ Ruby ⓘ |
| commonExampleDomain |
UI frameworks lifecycle methods
ⓘ
data parsing ⓘ document processing ⓘ game loops ⓘ |
| consequence |
base class controls algorithm flow
ⓘ
subclasses control specific steps but not algorithm order ⓘ |
| definedIn | Design Patterns: Elements of Reusable Object-Oriented Software ⓘ |
| defines |
primitive operations to be implemented by subclasses
ⓘ
skeleton of an algorithm in a base class ⓘ template method that calls primitive operations in a fixed order ⓘ |
| delegates | variable parts of an algorithm to subclasses ⓘ |
| differsFrom | Strategy pattern by using inheritance instead of composition for variation ⓘ |
| encapsulates | invariant parts of an algorithm in a base class ⓘ |
| ensures | consistent algorithm execution across subclasses ⓘ |
| hasCategory | behavioral pattern ⓘ |
| intent | define the skeleton of an algorithm in an operation, deferring some steps to subclasses ⓘ |
| mayDefine | hook operations with default behavior ⓘ |
| originatedFrom | work of Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides ⓘ |
| participantsInclude |
abstract class
ⓘ
concrete subclass ⓘ hook operations ⓘ primitive operations ⓘ template method operation ⓘ |
| preserves | overall algorithm structure ⓘ |
| promotes |
Hollywood principle: "Don’t call us, we’ll call you"
ⓘ
code reuse ⓘ inversion of control ⓘ |
| reduces | code duplication across subclasses ⓘ |
| relatedTo |
Factory Method
ⓘ
surface form:
Factory Method pattern
Strategy pattern ⓘ |
| separates | common algorithm structure from specific implementations ⓘ |
| supports | framework extension without modifying core algorithm ⓘ |
| typicalUseCase |
algorithms with stable structure and varying steps
ⓘ
frameworks defining fixed processing steps with customizable details ⓘ |
| uses | inheritance for specialization ⓘ |
Referenced by (3)
Full triples — surface form annotated when it differs from this entity's canonical label.
Design Patterns: Elements of Reusable Object-Oriented Software
→
describesPattern
→
Template Method
ⓘ
this entity surface form:
Template Method pattern