PHP Adapter mode object Adaptation Code Analysis <?php//Adapter mode-Object Adaptation/** * needs to be adapted class * Requirements: Add a new method to source but do not modify source source code */class source{public function Action () {echo ' Call action ', ' <br/> ';}} Interface targetable{/** * Method with the same name in the Source class, * Method not required in the adapter
1. PHP Adapter mode object Adaptation Code Analysis
Brief: <?php//Adapter mode-Object Adaptation/** * needs to be adapted class * Requirements: Add a new method to source but do not modify source source */class Source{public function action () {Ech O ' Call action ', ';}} Interface targetable{/** * Source class with the same name
2. How to implement the Java adapter (Adapter) mode
Summary: Usually we often encounter this situation, there are two of ready-made classes, there is no connection between them, but we now want to use one of the methods of the class, but also want to use another class method. One solution is to modify their respective interfaces, but this is the last thing we want to see. This time, adapter mode will come in handy. There are three ways to adapter mode, one is object adapter, one is class adapter, and the other is interface adapter The following example shows: public class Drawrecta
3. Use instances of the adapter adapter pattern in Python design mode programming
Introduction: This article mainly introduces the Python design pattern programming in the use of adapter adapter mode, in general, the adapter mode can be subdivided into class adapter and object adapter mode, the need for friends can refer to the following