A new component or dependency is not compatible with the current system architecture.
Convert the interface for the incompatible object into something that the rest of the system expects and understands. Wrap an existing class with a new interface.
- Bridge (Bridge intends to make things work as they are bring designed, Adapter intends to make older incompatible things work with the current system)
Just as we use adapters for hardware, software often needs an adapter to ease communication between the parts. The Adapter pattern is about creating an intermediary interface object that we can use to talk to incompatible or legacy components.
Many adapters are found in the real world. Display cables are found in several variations (VGA, DVI, DisplayPort, HDMI). The display device that you would like to connect to does not always have the same port as your device. We use adapters to enable the use of these cables and displays.
A database interface in any language is an adapter for systems that aren't directly compatible.
$db = new OracleOCI('localhost', 'sys', 'password', 'schema'); $query = "select * from DUAL"; $results = $db->query($query); while($data = oci_fetch_object($results)) echo $data->DUMMY;