Mid
From PDF
GoF Patterns
Gang of Four Patterns
Strategy Interface (ISortStrategy):?
Short answer: The ISortStrategy interface defines a common method (Sort) that all concrete strategies must implement. This allows clients (in this case, the Sorter class) to work with any strategy that implements this interface. public interface ISortStrategy
Example code
{ void Sort(List<int> list); }
Real-world example (ShopNest)
Discount rules are Strategy objects: PercentageOff, FlatOff, BuyOneGetOne—checkout picks one without a huge if/else.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png