Template Method Pattern
A pattern where a base class fixes the steps and child classes fill some of them in.
What is Template Method Pattern?
The Template Method pattern puts the fixed steps of a process in a base class and lets child classes fill in certain steps. Every report is "header, body, footer", but the body differs.
public abstract class Report
{
public string Build() => Header() + Body() + Footer();
protected string Header() => "ACME Corp\n";
protected abstract string Body();
protected string Footer() => "\n-- end --";
}
Level: Master · More OOP terms at this level
Updated