wood burning stoves 2.0*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Demystifying Bridge Pattern? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Demystifying Bridge Pattern?" Watch "Demystifying Bridge Pattern?" New topic
Author

Demystifying Bridge Pattern?

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
The intent of this pattern is to decouple abstraction from implementation so that the two can vary independently.

This seems to be like confusing statement to the readers. Since abstraction do always have implementation. Implementation is derived from abstraction. Abstract interface will have implementation. So in a sense implementation is tied to abstract interface.

But in above pattern, abstraction and implementation are totally used in different context. It does not means here the writer is talking same implementation of that abstraction. In reality, this abstraction and implementation are independent of each other. It's like they are overriding the meaning of abstraction and implementation.

If you are one of those who agree to above my point of view or understand better than me enough to clear me. do post.

Thanks

SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Thorin Potjes
Greenhorn

Joined: Aug 27, 2011
Posts: 14

Hi Amandeep,

The example I always use for Bridge is a light and light switch:
The light switch is the abstraction: you want the light to be turned on or off, or perhaps use a dimmer. The 2 abstractions are thus an on/off switch and a dimmer.

The actual light itself is the implementation: it might be a light bulb (bad for environment), an LED or a halogen light. It implements your light requirement: it will turn on or off, or give 50% light if you've set your dimmer half way.

I agree that the word 'abstraction' is somewhat confusing, as it is normally used in the context of interfaces and inheritance.

Hope this helps


'Design Patterns for Java' trainer
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
Thanks for reply.

I got your very good example. This example means to me that you can multiple version of light like bulb, led, tube etc and so you can multiple versions of light switch like dimmer, on/off.

These multiple versions of light and light switch can work together through bridge. Since light and light switch can have multiple versions, this means they can vary independently.
Thorin Potjes
Greenhorn

Joined: Aug 27, 2011
Posts: 14

Amandeep Singh wrote:Thanks for reply.

I got your very good example. This example means to me that you can multiple version of light like bulb, led, tube etc and so you can multiple versions of light switch like dimmer, on/off.

These multiple versions of light and light switch can work together through bridge. Since light and light switch can have multiple versions, this means they can vary independently.


exactly!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Demystifying Bridge Pattern?