Introduction to adapter pattern of Java design pattern
•
Java
Adapter pattern definition: two incompatible classes are used together. It is a structural pattern and requires two identities: Adaptee and adapter.
Why use adapter mode
We often encounter the need to combine two unrelated classes. The first solution is to modify the interfaces of their respective classes, but if we don't have source code, or we don't want to modify their interfaces for an application. What should I do?
Using the adapter, create a hybrid interface (hybrid) between the two interfaces.
How to use adapter mode
There are two ways to implement the adapter: composition and inheritance,
Suppose we want to pile, there are two kinds: square pile and circular pile.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码