© Dmitri Nesteruk 2020
D. NesterukDesign Patterns in .NET Core 3https://doi.org/10.1007/978-1-4842-6180-4_24

24. Template Method

Dmitri Nesteruk1  
(1)
St. Petersburg, c.St-Petersburg, Russia
 

The Strategy and Template Method design patterns are very similar, so much so that, just like with factories, I would be very tempted to merge those patterns into some sort of “Skeleton Method” design pattern. I will resist the urge.

The difference between Strategy and Template Method is that Strategy uses composition (whether static or dynamic), whereas Template Method uses inheritance. But the core principle of defining the skeleton of an algorithm in one place and its implementation details in other places remain, once again observing OCP (we simply extend ...

Get Design Patterns in .NET Core 3: Reusable Approaches in C# and F# for Object-Oriented Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.