Thursday, February 12, 2009

Adapter Design Pattern

Adaper Design Pattern or Wrapper Pattern:
Adapter is not a new word in english dictionary. You use adapter to connect your laptop with the electric socket. You can view your laptop as a class and the electric socket as an interface. Your laptop (class) wants to get some functionality via the interface (electric socket) but it does not understand this interface (electric socket). In other words you can say that laptop and electric sockets are incompatible. To make them compatible you require adapter.
Thus adapter design patter convert the existing interface (electric socket) into an interface(adapter) which the client(laptop) can understand. Thus Adapter design pattern achieves compatibility and reusability of the unrelated classes in an application.

Examples of Adapter Design Pattern:
The famous adapter classes in Java API are WindowAdapter, ComponentAdapter, ContainerAdapter, FocusAdapter, KeyAdapter, MouseAdapter and MouseMotionAdapter

No comments:

Post a Comment