From 1f1854436801b126ba7df0f528fd7b959e31ca17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Sun, 24 Aug 2014 23:37:24 +0300 Subject: [PATCH] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a207886c1..4627202f7 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,14 @@ ##Strategy **Intent:** Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. +![alt text](https://github.com/iluwatar/java-design-patterns/blob/master/strategy/etc/strategy.jpg "Strategy") + +**Applicability:** Use the Strategy pattern when +* many related classes differ only in their behavior. Stratefies provide a way to configure a class eith one of many behaviors +* you need different variants of an algorithm. for example, you migh define algorithms reflecting different space/time trade-offs. Strategies can be used when these variants are implemented as a class hierarchy of algorithms +* an algorithm uses data that clients shouldn't know about. Use the Strategy pattern to avoid exposing complex, algorithm-specific data structures +* a class defines many behaviors, and these appear as multiple conditional statements in its operations. Instead of many conditionals, move related conditional branches into their own Strategy class + ##Template method **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.