I was reading about Strategy Design pattern
but not able to understand what is significance of this and how and where it is useful? Can some one explain this design pattern with its significance and where it is useful in programming?
Asked
Active
Viewed 176 times
-3

Programmer
- 455
- 2
- 8
- 25
-
See this answer: http://stackoverflow.com/a/370270/20654 which may be a good example of the strategy pattern – OscarRyz Aug 14 '13 at 07:16
-
another example in java can be found at http://javabyranjith.blogspot.in/2017/04/strategy-design-pattern.html – Ranjith Sekar Apr 06 '17 at 08:04
1 Answers
3
Consider java.util.Comparator
. It defines the way two objects are compared. A TreeSet
created with different implementations of Comparator will sort elements in different ways. Another example from Java SE is java.util.concurrent.RejectedExcecutionHandler
which determines policy to process tasks rejected by ThreadPoolExecutor

Philipp Reichart
- 20,771
- 6
- 58
- 65

Evgeniy Dorofeev
- 133,369
- 30
- 199
- 275
-
So for any problem, the diffrent solution in our mind is the strategy design patern – Programmer Aug 14 '13 at 07:28
-
It might be put as a class designed to determine behaviour of another class. – Evgeniy Dorofeev Aug 14 '13 at 07:30