From 015b1d3f9a1338ed9db524b0bdf67b37a581f90f Mon Sep 17 00:00:00 2001 From: Petrutiu Mihai Date: Sat, 2 Jul 2016 16:06:50 +0300 Subject: [PATCH] Add description and when to use strategy pattern --- .../StrategyPatternExamples.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/StrategyPattern/StrategyPatternExamples.cs b/src/StrategyPattern/StrategyPatternExamples.cs index 59a2b6a..906bcea 100644 --- a/src/StrategyPattern/StrategyPatternExamples.cs +++ b/src/StrategyPattern/StrategyPatternExamples.cs @@ -6,16 +6,43 @@ using System.Threading.Tasks; namespace StrategyPattern { + /// + /// Client + /// public class StrategyPatternExamples { public static void Run() { + Console.WriteLine(GetDescription()); + Console.WriteLine(WhenToUse()); + GoToNextStep(); ShippingMotivatingExample.Run(); ShippingWithStrategyExample.Run(); - //TODO: use actions/funcs, add more examples + //TODO:add more examples //Show the switch moving problem } + + private static string GetDescription() + { + return @"Strategy pattern (also known as the policy pattern) is a software design pattern +that enables an algorithm's behavior to be selected at runtime. The strategy pattern +defines a family of algorithms, +encapsulates each algorithm, and +makes the algorithms interchangeable within that family."; + } + + public static string WhenToUse() + { + return @"Whenever you start to use a switch statement you should ask yourself whether you can use Strategy Pattern instead. "; + } + + + private static void GoToNextStep() + { + Console.ReadKey(); + Console.Clear(); + } } }