Design Pattern: Adapter

The Adapter pattern is a structural pattern that allows two objects with incompatible interfaces to interact. Adapter pattern is also known as a wrapper.

UML Diagram Example

RoundHole that has a function called fits() that takes in a RoundPeg object and returns if it fits. We also have a SquarePeg class that creates incompatible objects, lucky we have our SquarePegAdapter class that implements the roundPeg and that takes in a a SquarePeg object and making it compatible with RoundHole class

Leave a comment

Create your own website, free on WordPress.com.Create your own website.
Start free