-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplateMethod.cs
More file actions
21 lines (19 loc) · 1008 Bytes
/
TemplateMethod.cs
File metadata and controls
21 lines (19 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace DesignPatterns.Behavioral.TemplateMethod;
/// <summary>
/// Template Method Pattern
///
/// Intent: Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
/// Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
///
/// When to use:
/// - When you want to implement the invariant parts of an algorithm once and leave subclasses to implement behavior
/// - When common behavior among subclasses should be factored and localized in a common class
///
/// Real-world analogy: A recipe — the steps are fixed (prep, cook, serve),
/// but the specific ingredients/techniques vary by dish.
/// </summary>
// TODO: Implement Template Method
// 1. Abstract class with a template method (defines algorithm steps)
// 2. Abstract methods for steps that subclasses must implement
// 3. Concrete subclasses implementing the specific steps
// 4. Optional: hook methods that subclasses can optionally override