The strategy pattern is a way of thinking, a plan of action. Whether you might know it or not, you've probably implemented it already in some past project of yours :)
I'll suggest going about like so:
- Classify your project up in parts. Try to identify the things that are more dynamic (the things that change more frequently in your application). Then identify the more static parts.
- If some group(s) of your dynamic parts/components have something in common, well then you might have an opportunity to employ the strategy pattern !!
By encapsulating the dynamic parts of your application into objects, you'll be able to break the inheritance layer structure. I've recently found that if you've got a heavy layered structure, consisting of several layers build on top of one another, re-factoring becomes a pain (TDD/XP). In that case consider the strategy pattern as a good alternative.
Instead of your interface build on layers upon layers of code, try delegating objects to do the particular task for you. Inject them into your structure and see your overall structure being simplified.
0 comments:
Post a Comment