Adapter pattern can be applied for classes and for objects.
In Class Adapter;

the adapter class multiple inherits adoptee class and the clients target (interface) class. Because JAVA does not permit multiple inheritances, either one has to be adapted as Java interface type.
In Object Adapter;
In Object Adapter; Adapter contains the instance of the Adaptee and inherits the Client’s Target interface. When Client calls Target object the request is translated into request of the Adaptee object.Image Source:
http://staff.aist.go.jp/y-ichisugi/ja/mj/design-pattern/fig-GoF/PNG/adapter1.png
http://staff.aist.go.jp/y-ichisugi/ja/mj/design-pattern/fig-GoF/PNG/adapter2.png
No comments:
Post a Comment