Yeah, this is a complex pattern. I'll see if I can explain it properly.
Grand writes "The Birdge pattern is useful when there is a hierarchy of abstractions and a corresponding hierarchy of implementations." (I'm not convienced hierarchy is necessary, just that there be many implementations.)
Basically, you create a nice, simple implementation agnostic class to represent something. Then you have a series of concrete, kind of vendor specific, classes. You can't always stick the latter into the former easily, especially since he implementation classes may feel slightly different, so you need to bridge them.
Hmm, that's not very clear.
OK think of
Java's AWT. You have a whole bunch of GUI classes, button, checkbox, etc. These are very nice, platform independent classes. They need to be implemented in a platform specific way (Windwos, Mac OS, X,Truffle, etc). So there's a set of implementation classes, like WindowButton and WindowCheckbox,and also MacButton and MacCheckbox (you'll find these in java.awt.peer, although my actual names are problably wrong). The JVM then uses the appropriate GUI component implementation on a aprticular OS when a new GUI object is created. To make it easier for the peer class to fit into the abstract GUI class (here abstract means high level concept, as opposed to can't instantiate), i.e. Button, there's a nice interface to let the two work together. This intrface defines the relationship between Button and <OS>Button. This interface is the bridge. This means the <OS><Widget> implementor simply needs to implement to the interface and then can trust that <Widget> can use it.
I think of it kind of like an adaptor for a set of implementation classes.
Does that help?
--Mark
[email protected]