This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help understand bridge design pattern

 
Tapio Niemela
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey, I'm bit confused about this design pattern. Searching the web I can find mostly examples that are unrealistic, hard-to-understand (maybe requires some gui framework knowledge) or somehow violate other OO concepts, there's good example on http://www.developer.com/design/article.php/10925_3732061_1 . I can clearly see advantages here, but still I'm bit confused about terms "abstraction" and "implementation" used in this context. And specially when to use it. More practical/realistical examples or any clarifications would be greatly appreciated

thanks in advance
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at http://today.java.net/pub/a/today/2004/10/29/patterns.html
 
Tapio Niemela
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply. So Bridge pattern is just "simply" combination of template method and strategy? Then it would make some sense, lots of examples were missing that template method part..
 
Ran Pleasant
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tapio Niemela wrote:thanks for your reply. So Bridge pattern is just "simply" combination of template method and strategy? Then it would make some sense, lots of examples were missing that template method part..

Tapio

Its more than just using the template and strategy patterns. Gamma et. al. state that the intent of the Bridge pattern is to, "Decouple an abstraction from its implementation so that the two can vary independently". The keywords here are "decouple" and "vary". The strategy pattern does the decoupling and the template pattern allows strategy subclasses to vary in a structured manner. For example, consider a large object that encapsulates a financial option on a bond. Using the Bridge pattern you could refactor out of this object the instructment being sold to allow it to encapsulates bond, stocks, etc. You could also use the Bridge pattern to refactor out the pricing model, with one strategy being a BlackScholesPriceModel class and another being a BinomialPricingModel class.

(There was a great article on the Bridge Pattern in the Journal of Object-Oriented Programming (JOOP) several years ago that used the above example)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic