


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



ParulParul PatelPatel Josh GoodrichJosh Goodrich JustinJustin PlotkinPlotkin JonasJonas WeiWei
Encapsulate different algorithms Encapsulate different algorithms
Strategy lets the alogorithm Strategy lets thealogorithm varyvary independantly from the clients that use it.independantlyfrom the clients that use it.
The Strategy pattern defines an abstract The Strategy pattern defines an abstract policy for performing an algorithm At thepolicy for performing an algorithm At the same time it provides multiplesame time it provides multiple mechanisms that can comply with thatmechanisms that can comply with that policy, thus letting mechanism varypolicy, thus letting mechanism vary independently from the policy required.independently from the policy required.
You have many related classed that differ You have many related classed that differ only in their behavior.only in their behavior.
You need different variants of an You need different variants of an algorithm.algorithm.
An algorithm uses data that clients An algorithm uses data that clients shouldn't know about.shouldn't know about.
It helps to avoid exposing complex, It helps to avoid exposing complex, algorithm-algorithm-specific data structures.specific data structures.
When you have several conditional When you have several conditional statements in the program.statements in the program.
The application must be aware of all the The application must be aware of all the strategies to select the right one for thestrategies to select the right one for the right situation.right situation.
Increased number of object Increased number of object
Context and the Strategy classes normally Context and the Strategy classes normally
communicate through the interfacecommunicate through the interface