all index.md files renamed to README.md for more compatibility with github
This commit is contained in:
		
							
								
								
									
										34
									
								
								strategy/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								strategy/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| --- | ||||
| layout: pattern | ||||
| title: Strategy | ||||
| folder: strategy | ||||
| permalink: /patterns/strategy/ | ||||
| categories: Behavioral | ||||
| tags: | ||||
|  - Java | ||||
|  - Difficulty-Beginner | ||||
|  - Gang Of Four | ||||
| --- | ||||
|  | ||||
| ## Also known as | ||||
| Policy | ||||
|  | ||||
| ## Intent | ||||
| Define a family of algorithms, encapsulate each one, and make them | ||||
| interchangeable. Strategy lets the algorithm vary independently from clients | ||||
| that use it. | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Applicability | ||||
| Use the Strategy pattern when | ||||
|  | ||||
| * many related classes differ only in their behavior. Strategies provide a way to configure a class either one of many behaviors | ||||
| * you need different variants of an algorithm. for example, you might 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 | ||||
|  | ||||
| ## Credits | ||||
|  | ||||
| * [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) | ||||
| * [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1) | ||||
		Reference in New Issue
	
	Block a user