© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. NesterukDesign Patterns in .NET 6https://doi.org/10.1007/978-1-4842-8245-8_25

25. 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 ...

Get Design Patterns in .NET 6: 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.