Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Adapter pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Overview== The adapter<ref name="GoF"/> design pattern is one of the twenty-three well-known [[Gang of Four (software)|Gang of Four]] design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse. The adapter design pattern solves problems like:<ref name="Adapter_Design_Pattern"/> * How can a class be reused that does not have an interface that a client requires? * How can classes that have incompatible interfaces work together? * How can an alternative interface be provided for a class? Often an (already existing) class can not be reused only because its interface does not conform to the interface clients require. The adapter design pattern describes how to solve such problems: * Define a separate <code>adapter</code> class that converts the (incompatible) interface of a class (<code>adaptee</code>) into another interface (<code>target</code>) clients require. * Work through an <code>adapter</code> to work with (reuse) classes that do not have the required interface. The key idea in this pattern is to work through a separate <code>adapter</code> that adapts the interface of an (already existing) class without changing it. Clients don't know whether they work with a <code>target</code> class directly or through an <code>adapter</code> with a class that does not have the <code>target</code> interface. See also the UML class diagram below.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)