1
Reply

.NET and Java J2ee Design pattern interview question :- What is the difference between Decorator and Adapter pattern?

    Answer:
     

    Below is the main difference between these two design patterns.

    Decorator Design pattern

    Used to deal with new behavior or responsibilities without affecting existing code.
    Provides a wrapper over objects to apply same method which yields different results based on whether the object invoked is granular or composite.
    Change of interface does not happen.
     
    Adapter Design pattern

    Mainly involved in converting interfaces as per the requirement of client
    Allows use of new libraries without changing existing methods
    Change of interface happens in this case
     

    Regards,
    Do visit our .NET design pattern and Java J2EE design pattern interview questions.