Search the web
Sign In
New User? Sign Up
dpexplained · Design Patterns Explained
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Bridge v Strategy - Confused!   Message List  
Reply | Forward Message #470 of 485 |
RE: [dpexplained] Bridge v Strategy - Confused!

Why isn't a Bridge just a Strategy being used by a polymorphic structure?
Very common question, Steve.

Here are a few reasons I can supply, and then perhaps Alan will add to this
if I missed something:

1) Strategy is usually about a single method, whereas Bridge is about an
entire interface (usually a pretty broad one, since all the implementations
need to "fit within it".

2) In a Strategy, the object to use is typically passed in each time the
context object is asked to perform the function in question. It's highly
dynamic. This means the client has to "know" about the strategy. In
Bridge, the implementation is usually held by the abstraction object (built
that way at construction time) for its entire life. It's fixed. Only the
factory that built the abstraction object needs to "know" about the
bridge... the client just calls the method(s) on the context object as if it
were doing everything itself.

3) In a Strategy, the context object uses the strategy object the same way
each time (there's usually only one method, so that's a given). In Bridge,
each of the various abstraction objects uses the implementation interface
differently. It's a far more complex relationship.

You can also look at the motivations of the patterns:

Strategy is about varying a function polymorphically, as opposed to using
inheritance, to make the variation dynamic and to allow for multiple
variations without weakening cohesion.

Bridge is about one variation using another variation, without using
inheritance and suffering the class explosion and cohesion problems it
implies.

Hope this helps!

-Scott-

Scott Bain
Senior Consultant
Net Objectives
425-531-0812
http://www.netobjectives.com
----------------------------
Net Objectives' vision is effective software development without suffering.
Our mission is to assist software development teams in accomplishing this
through a combination of training and mentoring.


> -----Original Message-----
> From: stevebate2003 <stevebate2003@...>
> [mailto:stevebate2003@...]
> Sent: Monday, January 13, 2003 2:15 AM
> To: dpexplained@yahoogroups.com
> Subject: [dpexplained] Bridge v Strategy - Confused!
>
>
> Hello all,
>
> The tiitle says it all really.
> There I was, progressing fine through this excellent book when I hit
> upon the Strategy pattern. Is it just me or does it seem very similar
> to the Bridge pattern? Maybe I just need to re-read it and let it
> sink in a bit more and all will become clear? On the other hand, a
> nice little table like the one on page 105 (detailing the differences
> between Facade and Adapter) would be really cool.
>
> Can someone nail down the differences for me please?
>
> Many thanks
>
> Steve
>
>
>
>
> To unsubscribe from this group, send an email to:
> dpexplained-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>




Mon Jan 13, 2003 3:20 pm

slbain@...
Send Email Send Email

Forward
Message #470 of 485 |
Expand Messages Author Sort by Date

Hello all, The tiitle says it all really. There I was, progressing fine through this excellent book when I hit upon the Strategy pattern. Is it just me or does...
stevebate2003 <steveb...
stevebate2003
Offline Send Email
Jan 13, 2003
2:14 pm

Why isn't a Bridge just a Strategy being used by a polymorphic structure? Very common question, Steve. Here are a few reasons I can supply, and then perhaps...
Scott L. Bain
slbain@...
Send Email
Jan 13, 2003
3:18 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help