Design Patterns Java™ Workbook

(Michael S) #1
Chapter 6. Bridge

CHALLENGE 6.2


Draw a diagram that shows the relationships among the classes JDBCAdapter,
OzJDBCAdapter, NoQuery, and Statement.

The JDBC architecture clearly divides the roles of the driver writer and the application writer.
In some cases, this division will not exist in advance, even if you are using drivers. You may
be able to set up drivers as subclasses of an abstract superclass, with each subclass driving a
different subsystem. In such a case, you can be forced to set up a BRIDGE when you need
more flexibility.


Refactoring to Bridge...................................................................................................................................


Sometimes, you have to refactor an abstract class into a BRIDGE to gain more flexibility in the
abstraction. Consider the MachineController hierarchy at Oozinoz. Other than database
drivers, the most common application of drivers is to operate external devices. These devices
may be peripherals, such as printers and pen plotters, or any machine capable of
communicating with computers. Applications at Oozinoz control most of the machines on
the factory floor with the drivers, or controllers, that Figure 6.4 shows.

Free download pdf