The Adapter pattern is typically used to allow the reuse of a class that is similar, butnot the same, as the class the client class would like to see. Typically the originalclass is capable of supporting the behavior the client class needs, but does not havethe interface the client class expects, and it is not possible or practical to alter theoriginal class. Perhaps the source code is not available, or it is used elsewhere andchanging the interface is inappropriate.Here is an example that wraps OldClass so a client class can call it using amethod, NewMethod() defined in NewInterface:public class OldClassAdapter implements NewInterface {private OldClass ref;public OldClassAdapter(OldClass oc){ref = oc;}public void NewMethod(){ref.OldMethod();}}
Java
Topic: Design pattern
Explain the Adapter pattern?
Browse random answers:
What is the design pattern?
Do I have to use the design pattern?
How many design patterns?
What is the relationship among these patterns?
What is a software design pattern?
What is an analysis pattern?
What are the differences between analysis patterns and design patterns?
What is Singleton pattern?
Explain the Observer pattern?
Explain the Strategy and Template patterns?
Explain the Single Thread Execution pattern in concurrency patterns?
What are the structural patterns ?
Explain the Adapter pattern?
Expain the Proxy and Decorator patterns?
Explain the Composite pattern?
What are Behavioral patterns?
Explain the Observer pattern?
Explain the strategy and template patterns
Explain the concurrency patterns?
Explain the Single thread execution pattern?
Explain Design Patterns template?
Explain Patterns in Java template?