Converts an interface of a class to another interface that the customer wants. classes that are originally incompatible and cannot work together can work together.
The code is as follows:
/**
* Adapter mode
*
* Convert an interface of a class to another interface that the customer wants. classes that are originally incompatible and cannot work together can work together.
*/
// This is the original type
Class OldCache
{
Public function _ construct (
Converts an interface of a class to another interface that the customer wants. classes that are originally incompatible and cannot work together can work together.
The code is as follows:
/*** Adapter mode** Convert an interface of a class to another interface that the customer wants. classes that are originally incompatible and cannot work together can work together.*/// This is the original typeClass OldCache{Public function _ construct (){Echo
Copy the code code as follows:
/**
* Adapter Mode
*
* Convert a class's interface into another interface that the customer wants, using classes that are inherently incompatible to work with and can work together
*/
This is the original type.
Class Oldcache
{
Public Function __construct ()
{
echo "Oldcache construct}
Public function Store ($key, $value)
{
echo "Oldcache store}
Public function Remove ($key)
{
echo "Oldcache remove}
Public function F
In STL algorithms, function pointers and function-like passing algorithms can be used.
So why do we still need regular function adapters?
Because regular function adapters do not have the "matching capability"
Example:
/** File: Main. CPP * Author: Vicky. H * mail: eclipser@163.com */# include
5
Member function adapter:
/** File: Main. CPP * Author: Vicky. H * Email: eclipser@163.com */# include
BCDB---------------------------BCDB
In the book "Java and Patterns" of Dr. Shanhong, this describes the adapter (Adapter) Pattern:The adapter mode transforms the interface of one class into another interface that the client expects, so that two classes that would otherwise not work together because of an interface mismatch can work together.
purpose of Ad
In the book "Java and Patterns" of Dr. Shanhong, this describes the adapter (Adapter) Pattern:The adapter mode transforms the interface of one class into another interface that the client expects, so that two classes that would otherwise not work together because of an interface mismatch can work together.
purpose of Ad
Quote Encyclopedia
In computer programming, adapter patterns (sometimes referred to as wrapper styles or wrappers) fit the interface of a class to what the user expects. A fitting allows a class that is usually not working together because the interface is incompatible, by wrapping its own interface in an existing class.
Basic Information
There are two types of adapter modes: Class
Generally, the client class accesses the services it provides through the class interface. Sometimes, an existing class (existing class) can provide the functional requirements of the customer class, but its interfaces are not necessarily expected by the customer class. This is because the existing interface is too detailed or lacks details or the interface name is different from the one found by the customer class.
In this case, the existing interface needs to be converted to the desired interf
Thanks to "The Android source design pattern analysis and the actual combat" He Honghui Guan
The adapter pattern is extremely high in our development and can be judged from the adapter that are ubiquitous in the code, from the earliest ListView, the GridView, to the current Recyclerview all need to use adapter, and the optimization problems we encounter in devel
regularly updated on the official blog of guoshi studio. Please visit the blog of guoshi studio.
Http://www.cnblogs.com/guoshiandroid/get more updates.
Adapter Mode Laptop Adapter
Adapter ModeUse Cases:
MM's form was a mess, and promised mm to send her a notebook. Mm may be broken down. ^_^ but because cousin and mm are not in the same city, the lapto
Android source code: ListView adapter ModeMode definition
The adapter mode converts an interface of a class into another interface that the client expects, so that the two classes that cannot work together due to interface mismatch can work together.Use Cases
Using Power interfaces as an example, the power supply of laptops generally accepts 5 V voltage, but the voltage of wires in our daily life is general
Introduction
In project development, there are times when you need to use "some existing objects" that were previously developed, but the interfaces required in the new environment are not satisfied by these existing objects. How do you respond to the need for such migrations? This makes it possible to reuse these objects to meet the new application environment, which is the problem that the adapter (Adapter
The adapter mode converts an interface of a class into another interface that the client expects, so that the two classes that cannot work together due to interface mismatch can work together.________________________________________Usage of the adapter ModeUsing electrical appliances as an example, the plug of the laptop is generally three-phase, that is, in addition to the anode and cathode, there is also
In the book "Java and Patterns" of Dr. Shanhong, this describes the adapter (Adapter) Pattern:The adapter mode transforms the interface of one class into another interface that the client expects, so that two classes that would otherwise not work together because of an interface mismatch can work together.
purpose of Ad
This article describes the adapter mode (Adapter pattern), the adapter mode used in the development of the frequency is also very high, such as the ListView and Recyclerview Adapter, etc. are used in the adapter mode. In our real life there are a lot of examples like adapter
What is the adapter, said the text, the adaptation should be a verb, and the use of ancient prose should be used to make use of the law, translation into, so ... A device that fits the old things and works with new things.Once upon a time, I was fortunate enough to have sold a laptop, and it was there that I first heard the word adapter. A small black block connected to the power supply and computer, which
ArticleDirectory
I. Review of the previous Article
Ii. Summary
Iii. Outline
Iv. Features and Use Cases of the adapter Mode
5. Classic Implementation of the adapter Mode
6. other solutions in the adapter Mode
VII. Adapter mode usage Summary
8. Series progress
IX. next announcement
I.
The adapter mode transforms the interface of one class into another interface that the client expects, so that two classes that would otherwise not work together because of an interface mismatch can work together.purpose of Adapter modeUsing electrical appliances As an example, the laptop plug is generally three-phase, that is, in addition to the anode, cathode, there is a polar. And in some places the po
ArticleDirectory
Misuse reason
Last issue review
As mentioned above, a user has taken the industry standard switch (a standard standardswitcher, which relies on the istandardswitchable interface to work, but currently our lamp does not support this interface) and appears in front of me, he shouted that his "Standard switch" should be able to turn on our lights. Well, this requirement is reasonable and should be supported. But the damn thing is, why didn't we know the standard as ea
Subsequent content will include the following architectural patterns:
Adapter mode (Adapter): Match interfaces of different classes synthesis mode (composite): A tree structure The simple and composite decorative mode ( Decorator): Add responsibilities to Objects dynamically proxy mode (proxy): An object representing another Object-sharing Mode (Flyweight): A fine-grained instance used for efficient sharin
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.