The adapter pattern

By | March 21, 2018

The adapter pattern is a structural pattern also known as a wrapper pattern. It is mostly commonly used in software engineering where the adaptee can not be altered as it is outside the control of the system and the developer.

To contain this volatility the adaptee is wrapped by a class that exposes the functionality of the adaptee. By doing this if needed the adaptee can be replaced at a later time with minimal affect to the rest of the system.  Note this is not inheritance.

Below is a more practical example of an adapter pattern.

In this example the adapter is the CompressionHelper and the adaptee is the ZipLbrary. The classes represented in the grey color are possible alternatives that can be swapped into the system in any time with limited to no impact to the rest of the application. The volatility will be contained within the compression helper.

Leave a Reply

Your email address will not be published.