-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrategy.cs
More file actions
22 lines (20 loc) · 943 Bytes
/
Strategy.cs
File metadata and controls
22 lines (20 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace DesignPatterns.Behavioral.Strategy;
/// <summary>
/// Strategy Pattern
///
/// Intent: Define a family of algorithms, encapsulate each one, and make them interchangeable.
/// Strategy lets the algorithm vary independently from clients that use it.
///
/// When to use:
/// - When many related classes differ only in their behavior
/// - When you need different variants of an algorithm
/// - When an algorithm uses data that clients shouldn't know about
/// - To avoid complex conditional statements for selecting behavior
///
/// Real-world analogy: A navigation app — you can choose driving, walking, or cycling
/// route strategy. Each uses the same destination but different algorithms.
/// </summary>
// TODO: Implement Strategy
// 1. Strategy interface (e.g., IRouteStrategy)
// 2. Concrete strategies (e.g., DrivingStrategy, WalkingStrategy)
// 3. Context class that holds a strategy reference and delegates to it