aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Bridge and Facade Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Bridge and Facade Pattern" Watch "Bridge and Facade Pattern" New topic
Author

Bridge and Facade Pattern

S Hussain
Greenhorn

Joined: Jul 07, 2005
Posts: 5
I am working through various patterns. One thing I am not clear about is how Bridge pattern differs from Facade? Both patterns have same (almost) functionality -- i.e., they translate information between two separate layers, and/or components.

-s hussain
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Moving to our Patterns forum.


[Jess in Action][AskingGoodQuestions]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sometimes patterns have very similar UML diagrams but different intent. I'd use facade if I were building a set of services for other clients to use and I'd like to make a single, simplified API for them to use so I don't have to explain all the complicated objects I have. It's kind of a courtesy to my clients.

How would you see the motivation to write a bridge being different? I only ask because I haven't read Bridge recently enough to say myself.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 189
My understanding of bridge pattern is to horizontally separate interface (API) from implementation. For example, a contract, API, is defined for an application. The implementations can be different but as long as they fulfilled the contract, they can be plugged in either directly or indirectly via adapter.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

A bridge is created to seperate the implementation from the API. A bridge tends to be created to support pluggability of the implementation into different APIs.

A facade is an API created on top of a set of APIs or methods. It provides the ability to interface with a single API where there are actually several.
[ July 28, 2005: Message edited by: CL Gilbert ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Stan is right - the most important difference is in the intent. Facade is about how to interface to the outside of a component, Bridge is more about organizing its internal structure.

On the other hand, in my copy of the GoF book, the diagrams for Facade and Bridge look quite different, so I'm not sure what similarities you see...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
S Hussain
Greenhorn

Joined: Jul 07, 2005
Posts: 5
Thanks folks.

Your replies have clarified distinction between Bridge and Facade pattern.
Though I still have to digest your replies.

-S Hussain
S Hussain
Greenhorn

Joined: Jul 07, 2005
Posts: 5
Ilja,
your URL take me to book description. Unfortunately I cannot read German (Danish ??).
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Don't stare at them too long else you will see the similarity in all patterns. the more you know the harder it will be to differentiate the patterns...
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by S Hussain:
Ilja,
your URL take me to book description. Unfortunately I cannot read German (Danish ??).


Yes, it's German. It's the second edition of Unit Testing in Java, but unfortunately it didn't get translated to english like the first, sorry. The first edition is quite good too, though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bridge and Facade Pattern