Enterprise Application Architecture with .NET Core
by Ganesan Senthilvel, Ovais Mehboob Ahmed Khan, Habib Qureshi
The strategy pattern
The strategy pattern basically allows an algorithm to be selected dynamically at runtime without modifying the client code.
For example, if we have lot of input data from past weather information and we need to forecast the weather, we could perhaps infer based on purely statistical values from the past or from an algorithm doing some kind of scientific manipulation or both. After doing the calculations, we would want to compare the results to check the effectiveness, for example. In this scenario, instead of changing the client code each time, we just supply a different algorithm implementation to the client, thus incurring maybe just a single line of code change. So, the strategy pattern lets the algorithm vary independently ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access