> Design Patterns > Template Method Design Pattern
Template Method design pattern is used to get some steps of algorithm implemented in subclass.
The intent of template method design pattern is to defer some steps of algorithm to subclass without changing the algorithm structure.
There may be a situation where steps of algorithm are not known. For example, the framework has some steps of algorithm which are supposed to be provided by user. There may be many scenarios where some steps may vary but the algorithm is generic.
So the algorithm structure is not changed and some steps are deferred to be implemented by subclasses.
Here is the template method design pattern example.
Network Management Framework want to configure devices - system, printer, network etc. It should be done in 3 steps - Initialize, Configure and Save. Configure will differ for each device.
|C++||Template Method Pattern in C++||Template Method Pattern C++ Example|
|C#||Template Method Pattern in C#||Template Method Pattern C# Example|
|Java||Template Method Pattern in Java||Template Method Pattern Java Example|
|Python||Template Method Pattern in Python||Template Method Pattern Python Example|
|PHP||Template Method Pattern in PHP||Template Method Pattern PHP Example|
|Ruby||Template Method Pattern in Ruby||Template Method Pattern Ruby Example|
|Swift||Template Method Pattern in Swift||Template Method Pattern Swift Example|
|Objective-C||Template Method Pattern in Objective-C||Template Method Pattern Objective-C Example|