Adapter Pattern Type Class
Probably everyone have seen some adapters for memory cards.
Adapter pattern type class. It is typical for the expected interface to be created as a pure interface class especially in languages such as java before jdk 1 8 that do not support multiple inheritance of classes. This adapter pattern uses multiple polymorphic interfaces implementing or inheriting both the interface that is expected and the interface that is pre existing. There is also another type called class adapter pattern which use inheritance instead of composition but you require multiple inheritance to implement it. Like any adapter in the real world it is used to be an interface a bridge between two objects.
In real world we have adapters for power supplies adapters for camera memory cards and so on. Adapter pattern works as a bridge between two incompatible interfaces. Adapter design pattern translates the interface for one class into a compatible but different interface. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces.
Adapter class makes classes with incompatible interfaces work together adapter design pattern is a structural design pattern among the gang of four gof article on gof patterns their types design patterns. But the interface for the adapter class and the original class may be different. The adapter pattern deals with how the classes are composed to form larger. This pattern involves a single class which is responsible to join functionalities of independent or.
So this is similar to the proxy pattern in that it s a single component wrapper. The adapter pattern is adapting between classes and objects. These incompatible classes may come from different libraries or frameworks. This structural code demonstrates the adapter pattern which maps the interface of one class onto another so that they can work together.