5.6. Bridge

The Bridge pattern is a kind of super Strategy pattern, that is, it is a way of encapsulating alternate versions of a whole range of methods rather than encapsulating alternate versions of just one method.

The problem is that you may have a set of methods that you contemplate implementing in two or more completely different ways. You don’t want to have to mess up the rest of your code with the details of the different implementations.

The solution is to write a base class Interface that includes more or less empty implementations of the methods you need, and then to derive off Implementation child classes that provide concrete implementations of these methods. In the rest of the program, you program towards the somewhat abstract ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.