Adapter Pattern

Why Adapter Pattern

Solution

Class Diagram

Object and Class adapter
Above class diagram is for object adapter, below is class adapter.

- Object uses composition, class uses subclassing.
Let's take a example of Enumeration and Iterator. Task is to Adapt an Enumeration to an Iterator.


for remove() we will send UnsupportedOperationException.
Home Work - Adapt an Iterator to Enumerator
Decorator - Doesn't alter the interface, but adds responsibility.
Adapter - Converts one interface to another.
Facade - Makes an interface simpler.



