Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

MT2: What is the main feature of the adapter pattern which allows it to be so useful?

+17 votes
asked Oct 23, 2015 in Fall 15-16 by Scott Davis (100 points)

2 Answers

+8 votes
The main feature of the adapter pattern that makes it so useful is the sense that it serves as a "wrapper" class for the client. When the client wants to use a certain class but that class does not have the right interface, we can create an Adapter class that will basically link the two. This is useful because then the wrapper or Adapter class is the only class communicating with this other class said to be the Adaptee, and therefore the client does not have to worry about the issue of the incorrect interface. The code in the Adapter handles that issue completely.
answered Oct 24, 2015 by Jeffrey Prior (100 points)
+2 votes
Any classes can work together as long as the adapter solves the issue that all classes must implement every method defined by the shared interface.

https://www.youtube.com/watch?v=qG286LQM6BU

This is a tutorial video about adapter pattern, it's really helpful!
answered Nov 3, 2015 by Amiao Gao (100 points)
...