Understanding Bridge Pattern using .NET
page 2 of 13
by David Simmonds
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 46938/ 105

What does the bridge pattern allow us to do?

Think of a component set where the components are interchangeable.  You can upgrade the speakers for deeper bass.  If the CD-player goes bad, we can similarly buy a new CD-player and plug it into the Amplifier and we are good to go again.

The CD-Player (through the Amplifier) produces a signal which is not useful to human beings.  We still cannot hear the music.  We can, however, feed that signal into the speakers.  The signal will then cause an electro-magnet connected to the speaker’s cone to jump in tune with the music. This jumping of the speaker’s cone causes it to collide with air molecules surrounding it, thereby producing vibrations in the air which the human ear can actually hear.  Hence, we have an actual implementation.

In the bridge pattern there is an abstraction interface which dictates that any class implementing it must be able to create an abstraction of the work to be done.  In this tutorial I call it an expression of the work.  In the example used, this is equivalent to a specification for CD-players which will indicate that a CD-player must be able to produce a musical signal.  Also in the pattern are the refined abstractions.  I imagine the GoF avoided the term concrete-abstraction since it is a bit of an oxymoron.  These refined-abstractions are the actual classes which produce the expressions of work.  You could also think of them as the signal-producers.  In the example of the music system, these are CD-players, Tuners, Turntables, etc.

The bridge pattern also has an abstract implementer.  This is can be compared to a music-system specification for speakers which dictates that the device must accept a musical signal and produce an audible vibration based on that signal.  Finally, the pattern includes the concrete implementers.  These are like the actual speakers or headphones.  They accept the signal produced by the CD-player and vibrate their cones rapidly to produce something you can hear.  In fact, 20 years from now when energy is at a premium and we have to save every single watt (and they find a way to directly influence your brain waves) you can expect that speakers will evolve to become tiny electrodes which you clip on to your ears.  The point is that there is flexibility in the way the device works.  As long as you “hear” the music then that is all that matters because the music is “implemented.”

 


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-10 11:07:52 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search