Wednesday, April 18, 2007

Behavioral Patterns-Adapter

Adapter Pattern

As a student of PAFSD,this week i try to understand about the adapter pattern which will helpful for my coursework first question. After read a "Head first design pattern book and related websites i understood valuable information about adapter pattern help for software development.

What i learnt about this Pattern

The adapter pattern allows classes work together, which have incompatible interfaces in system. It acts as a middle man by receiving request from the client and converting them into request that make what exactly client expect. In software re-engineering or reuse process, some times we meet incompatible interfaces to join each other to run system.

The main reasons for this problem are took kit or class libraries are incompatible with interface with new system. Then software developer use adapter to create reusable class that corporate with incompatible interfaces to get exception interfaces. The following definition is the most understandable definition for me about the adapter pattern.

The following definition is the most understandable definition for me about the adapter pattern.

The Adapter Pattern

"converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces".
Head First Design Patterns- ISBN 0-596-00712-4

!!! When i was considering about the above things, i had question about adapter pattern.

What happen the systems have old system interface and new system interface? Its bit confusing to create a adapter pattern.

Further reading about the Head first book i realised we can create two way adapter to solve a this problem.The two way adapter supports both interfaces to match old vender class and new vender class.



Following link will give you good idea about the Adapter pattern.
http://www.research.umbc.edu/~tarr/dp/lectures/Adapter-2pp.pdf.

No comments: