Learn now: https://edu.csdn.net/course/play/28941/403580?utm_source=blogtoedu
Adapter: Convert the existing stable function to the function required by the target role
(1) Class adapter, inherit the function of the original role by inheritance, may not meet the least-know principle
(2) The object adapter is injected by the construction method, so that the function of the original role cannot be obtained by the target role, which conforms to the least-know principle
(3) Interface adapter, write all the related functions that may be involved in the interface, which is implemented by the target role, and inject the original role into it through construction; this does not conform to the single responsibility principle and interface isolation principle of the class. If you add a new one Demand, may not meet the opening and closing principle
actual case:
(1) The original login uses a registered account to log in
(2) For current needs, you can log in with qq, WeChat, etc., and use the adapter mode for compatibility