Introduction to the Adaptor design pattern

No.of Views1092
Bookmarked0 times
By  Chinna Srihari   On  23 Oct 2010 03:10:18
Tag : Design Patterns , General
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.
1.       Wrap an existing class with a new interface.
2.       Impedance match an old component to a new system
3.       Adapter, the modifier, is about creating an intermediary abstraction that translates, or maps to the old component to the new system. Clients call methods on the Adapter object which redirects them into calls to the legacy component. This strategy can be implemented either with inheritance or with aggregation.
4.       Adapter provides a different interface to its subject. Proxy provides the same interface. Decorator provides an improved interface.
Please refer to the code
Some of best example: Adaptor for Two pin plug, We can have only one adaptor
UML Diagram
From GoF
 Please refer to attached doc for images
    /// Target Wraper base
    public class AdaptorTarget
        public virtual void Request()
            Console.WriteLine("Called Target Request()");
    /// Adapter -- Wrapper
    public class Adaptor : AdaptorTarget
        internal OldSystem.Adaptee Adaptee
            get { return new OldSystem.Adaptee();}
            set { ;}
        public override void Request()
    namespace OldSystem
        /// Adaptee -- Old system
        internal class Adaptee
            internal void OldMethod()
                Console.WriteLine("Called incompatable system method....");
internal static AdaptorTarget AdaptorTargetLocal
                return new Adaptor();
        static void Main(string[] args)
Note: Adator provides wrapper for each system. Where are Façade does differently. And Proxy is also a wrapper but it exposes the same interfaces as the subsystem.
Hope this helps

Download Sample

Download source files -47 kb

Sign Up to vote for this article
About Author
Chinna Srihari
Occupation-Software Engineer
Member Type-Junior
Joined date-17 Jun 2010
Home Page-
Blog Page-
Having 12 + years of IT experience, 2.5 years as Technical Management experience and 1.5 year of onsite coordinator experience and rest 8+ years of technical activities including Project Leader, Tech Lead, Designer, PQL, and Developer experience in Quality Management System (CMM-level 5, SEI-CMM-level 5).
Other popularSectionarticles
    This is a quite simple design pattern, let me tell you one thing there are many design patterns that they are implicitly singletons. I rather recommend to understanding this one first before going through other patterns.
    Published Date : 21/Oct/2010
    As a developer we might have noticed that creation of some class is very difficult and number of time that we need to create. Such object creation every time is very expensive in terms of system resources. If we can cache that kind of object show how will surely boost the application performance and resource usage can be saved. This where object pool design pattern will help development community to cache the objects. Some time it is also called as Object cache or Resource cache design pattern.
    Published Date : 21/Oct/2010
    The Command pattern creates distance between the client that requests an operation and the object that can perform it.
    Published Date : 20/Sep/2010
    Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
    Published Date : 22/Oct/2010
    A fully initialized instance to be copied or cloned. The Prototype pattern specifies the kind of objects to create using a prototypical instance.
    Published Date : 22/Oct/2010
There is no comments for this articles.
Leave a Reply
Display Name:
(not display in page for the security purphase)
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top