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 (3)

How this entity was disambiguated

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 patterns ⓘ
canBeImplementedIn 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 pattern ⓘ
linked to: Factory Method

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 ⓘ

How these facts were elicited

Referenced by (6)

Full triples — surface form annotated when it differs from this entity's canonical label.

Factory Method → relatedTo → Template Method pattern ⓘ
linked to: Template Method
Strategy → relatedTo → Template Method pattern ⓘ
linked to: Template Method
Strategy pattern → relatedTo → Template Method pattern ⓘ
linked to: Template Method
Strategy (design pattern) → relatedTo → Template Method (design pattern) ⓘ
linked to: Template Method
Gang of Four design pattern → hasExample → Template Method pattern ⓘ
linked to: Template Method