About adaptation Source code introduction

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.