gang-of-4-patterns AT lists.siebelschool.illinois.edu
Subject: Design Patterns discussion
List archive
- From: Wayne Cannon <wcannon AT sonic.net>
- To: cfinlayson AT vls-inc.com
- Cc: gang-of-4-patterns AT cs.uiuc.edu
- Subject: Re: RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern
- Date: Fri, 07 Nov 2003 11:45:57 -0800
- List-archive: <http://mail.cs.uiuc.edu/pipermail/gang-of-4-patterns/>
- List-id: Design Patterns discussion <gang-of-4-patterns.cs.uiuc.edu>
I'm glad it was helpful to you. It was the most confusing bunch of responses I've seen in a long time.
Frequently (almost every problem) you will find that a combination of more than one pattern can be used to implement a solution. If you really read the descriptions, I think you will find that the GoF patterns themselves are pretty distinct from one another (maybe not in their structure, but in their use, intent, and the way the function -- as Paul Adolf pointed out).
The Bridge and Strategy patterns are very distinct. The Bridge pattern deals with HOW you deal with multiple implementations, while the Strategy pattern deals with USING different implementations to implement different algorithms. One way to implement the Strategy pattern is to use the Bridge pattern approach, but the Strategy pattern can also be implemented a number of other ways (e.g., via a switch statement). You can use the Bridge pattern approach to implement the Strategy pattern, but not vice versa (the Strategy pattern is not a HOW and the Bridge pattern care nothing about how it is USED)..
The State and Strategy patterns are distinct. This is going to sound familiar. The State pattern deals with HOW you switch between different states/implementations, while the Strategy pattern deals with USING different implementations to implement different algorithms. One way to implement the Strategy pattern is to use the State pattern approach, but the Strategy pattern can also be implemented a number of other ways. You can use the State pattern approach to implement the Strategy pattern, but not vice versa (the Strategy pattern is not a HOW and the State pattern cares nothing about how it is USED).
To carry this line of thought one step further, a Bridge pattern approach can be used to implement the State pattern, but the State pattern can also be implemented by other mechanisms. The State pattern includes a little bit of WHAT the switching implementations are used for -- to switch states -- while the Bridge pattern says less about how it is used and what it is used for.
The important point is that you may use multiple patterns to solve one problem -- indeed, you may choose to use one pattern to implement another pattern. For example, you may use a Bridge pattern to implement a State pattern, and the State pattern to implement a Strategy pattern. This does not make these patterns equal, or even similar, to one another. If anything, some patterns are lower-level concepts than other patterns. You frequently have multiple choices available to implement the higher-level patterns, only one of which might be a particular lower-level pattern.
Regards,
Wayne
Chris Finlayson wrote:
Hi all:
Thanks for all the prompt, thorough responses. It's been quite helpful.
Everyone's response has been terriffic.
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, (continued)
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, ziane, 11/06/2003
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Paul Adolph, 11/06/2003
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Mikal Ziane, 11/07/2003
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Paul Adolph, 11/06/2003
- Re: [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Wayne Cannon, 11/06/2003
- RE: [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Ray Ye, 11/06/2003
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Mikal Ziane, 11/06/2003
- RE: RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Chris Finlayson, 11/06/2003
- RE: RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, David Rosenstrauch, 11/06/2003
- State and strategy [was RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern], Peter Horan, 11/06/2003
- Re: State and strategy [was RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern], Wayne Cannon, 11/06/2003
- Re: RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Wayne Cannon, 11/07/2003
- RE: RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Chris Finlayson, 11/06/2003
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, Mikal Ziane, 11/06/2003
- RE : [gang-of-4-patterns] Strategy Pattern vs. Bridge Pattern, ziane, 11/06/2003
Archive powered by MHonArc 2.6.16.