Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bridge and Facade Pattern

 
S Hussain
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our Patterns forum.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vu lee
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
S Hussain
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilja,
your URL take me to book description. Unfortunately I cannot read German (Danish ??).
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic