Adapt or perish, now as ever, is nature’s inexorable imperative.
The presentations and conceptions of the average man of the world are formed and dominated, not by the full and pure desire for knowledge as an end in itself, but by the struggle to adapt himself favorably to the conditions of life.
The basic motivation for the adapter pattern is to enable wider use of existing classes. For example, let’s assume that there’s a class that does a particular job, and does it well. We want to use this class in an application, but it just doesn’t fit all the current requirements. We may want to expand its features, or combine it with some other classes to provide additional functionality. The bottom line is that we must adapt this existing class to fit new requirements. This is what the adapter pattern does; it allows a client to use an existing class by converting its interface into one that fits a new context. The key point to remember is that the existing class isn’t modified, but an adapter class that has the right interface uses it or extends it to provide the necessary functionality.
A good example of an adapter is the toilet seat adapter used by toddlers that fits on top of a traditional toilet seat. Let’s take a look at the context. We have a legacy object that is the toilet seat, whose basic design hasn’t changed in years. It functions well for its original adult users ...