We briefly discussed adapters earlier in the semester when discussing decorators, but didn’t go into much detail, because there is very little difference. For the sake of completeness, let’s review briefly.
Converts the interface of a class to another interface expected by clients. Lets classes work together that couldn’t otherwise because of incompatible interfaces
AKA: Wrapper
As mentioned before, the main difference between decorators and adapters is that decorators implement the same interface as what is being wrapped, while adapters use a different interface.
Note that when using adapters we lose the benefits of transparency that we obtain from using decorators.
Accordingly, we can “stack” decorators, but can only have one adapter of a given kind.
Provides a unified interface to a set of interfaces in a subsystem. Defines a higher level interface that makes the subsystems easier to use.
We can view facades as, basically, adapters which adapt multiple complex interfaces to a single, simple interface. In other words, they will often “wrap” more than one object, and expose their functionality in an adapted interface.