• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Demystifying Bridge Pattern?

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 14
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic