I'm trying to understand the Bridge pattern. With examples from Wiki all is ok. But what if we have the next design:
How can I implement different remote controls (e.g. Infra-red and Wi-Fi)? Should I use Bridge pattern and how to do it? By analogy with an examples I need to combine all methods to the single wide interface with hardware implementation like on the next figure. But I don't think it's a good idea.
The bridge pattern is a lot like the adapter pattern.
Following your model, let's suppose you have an
RemoteControl
abstract class:And two implementations for that class:
Now, for the hardware bridge, we have a base interface:
And two more interfaces:
And, as in your desing, two implementations:
From an external project, a client of your API may use the hardware more transparently, not even aware of these implementations: