As the name suggests the Strategy design pattern is dedicated to providing a strategy to the Client while the Decorator design pattern is dedicated to providing an enrichment of a certain functionality.
To be precise the two patterns respond differently to the following question:
Does the functionality need to be swapped or to be added?
- The design patter Strategy is used to swap different (very different) strategy most of the times.
- The design patter Decorator is used to add different behaviour (no necessary very different most of the times).
No comments :
Post a Comment