An image example:
(Adapter) I met Sarah, a beautiful girl from Hong Kong at a friend's party. But I can't speak Cantonese, and she can't speak Mandarin, so I have to turn to my friend Kent, as an adapter between me and Sarah, Sarah and I can talk to each other (I don't know if he will play with me ).
Adapter (transformer) mode:
The interface of a class is transformed into another interface expected by the client, so that the two classes that cannot work together due to interface mismatch can work together. The adaptation class can return a suitable instance to the client based on the parameters.
UML:
1) inherit the original Interface Class
2) combine original interface classes
Resolution:
The adapt mode is actually to bridge the classes that have completed the same function but are incompatible with the interfaces so that they can work together. This mode makes it possible to reuse the old interfaces.
Implementation:
The adapt mode has two implementation methods: one is to inherit the original interface class method, the other is to combine the original interface class method, the second method is used here.
Design Pattern _ adapt