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 Adapter
Design Mode-Adapter Mode)Basic Concepts
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.
In the GoF design mode, there are two types of adapter modes: Class adapter mode and
The adapter is easy to understand, most families have a mobile phone adapter that is used to charge the mobile phone, which is an adaptor. If you have only a USB connector, you cannot plug your mobile phone into a standard socket. In fact, an adapter must be used, one end connected to the USB plug, and the other end connected to the socket. Of course, you can tak
The adapter is easy to understand, most families have a mobile phone adapter that is used to charge the mobile phone, which is an adaptor. If you have only a USB connector, you cannot plug your mobile phone into a standard socket. In fact, an adapter must be used, one end connected to the USB plug, and the other end connected to the socket. Of course, you can tak
9.6 default Adapter
Default adapter ModeIt is a variant of the adapter mode and is widely used. The default adapter mode is defined as follows:
Default adapter pattern: When you do not need to implement all the methods provided by an interface, you can first design
An introduction to Adapter mode
What is adapter mode
Defined
Classification
What scenarios the adapter applies To
Two adapter mode applications in the Android framework
Listviewbaseadapter Custom View
Popular U
1. OverviewTransforms the interface of one class into another interface that the customer wants. The adapter mode makes it possible to work together those classes that would otherwise not work together because of incompatible interfaces.2. Issues to solveThat is, the adapter mode makes it possible for those classes that cannot work together because the interface is incompatible.Here are two very vivid examp
Adapter Mode (Adapter)
Defined
The adapter mode transforms the interface of a class into another interface that the customer expects, so that interfaces that are inherently incompatible can work together. "Head First design mode"Using electrical appliances As an example, the laptop plug is generally three-phase, that is, in addition to
1. OverviewDuring software development, we often encounter inter-system integration. The most common problem during system integration is the inconsistent interfaces between systems. Many system modules that can meet the requirements are unavailable due to inconsistent interfaces. For example, the commonly used media players are MS media player and RealPlayer. Their file structure and software interfaces are completely different. The former supports the WMF Format of audio and video, the latter
Reprint please indicate the source:http://blog.csdn.net/zxt0601/article/details/52848004
This article is from: "Zhang Xudong Blog" an overview
Definition: The adapter pattern transforms the interface of a class into another interface that the client expects, and the purpose of the master is to be compatible, so that two classes that would otherwise not work together because of an interface mismatch can work together. Its alias is the wrapper (Wrapper)
Adapter Definition:Adapter mode (Adapter pattern): Converts an interface into another interface that the customer wants, and the adapter mode can work with those classes that are incompatible with the interface, whose alias is the wrapper (Wrapper). The adapter mode can be either a class-structured pattern or an object
4. Adapter Mode SummaryIn the object adapter mode, the adapter is associated with the adaptation, and in class adapter mode, the adapter is an inheritance relationship to the appropriate person. whether an object adapter or a clas
Problems in the real world
There is a socket, this socket is three mouth, but we have only two tentacles of the plug, a stupid method is to directly force the two tentacles bent, inserted into (this kind of thing I have done), there is another way is to find a conversion head.Look at the following figure is probably clear, it is obvious that the existing system is difficult to match with vendors, how to do it? Well, the adapter is handy.
Some examples of life
In our daily life, for the adapter, can be said to be everywhere. For example, we usually use the notebook computer, may be the operating voltage of the laptop is 20V, but our general household electricity is 220V, this time when the computer is charged with a power adapter to the 220V of the computer to convert to 20V voltage. This power adapter
What is the adapter mode?
In computer programming, the adapter mode (sometimes called packaging style or packaging) adapts a class interface to what the user expects. The adapter can work together classes that cannot work together because of the incompatibility of interfaces, by encapsulating their own interfaces in an existing class.
How does one implement the
Adapter mode what is adapter Mode
The adapter mode is a structural mode that allows two unmatched interfaces to work together.
The adapter mode allows two unmatched classes to work collaboratively by converting one interface type to another interface type that the client expects.
The
In Series 1, the RM and MPEG classes inherit the videomedia abstract class, while the videomedia class implements the imedia interface, which only provides the play () method. Ice soda is intended to provide RM, MPEG with different attributes and methods than audiomedia. For example, for Video Media, there should be a method to adjust the screen size, such as resize (). This method is not available for the imedia interface.
So how does one provide the resize () method not available in the imed
experience reach a certain level, and it also means to summarize a lot of good design experience, however, it may not be the case that "no teacher can do anything", or you can say that, on the basis of level and experience, it is time for the system to learn the "mode, it is helpful to learn the experts' summary and verify your own shortcomings.
This series of design patterns learning notes is actually a Learning Record for the book "Java and patterns.
Adap
Android note 11. ListView + AdapterUnderstanding Adapter 1. ListViewListView is a common component in Android development. It displays data in the form of a list. Generally, a ListView consists of the following three elements:1. View: Displays the list view, which is usually specified by an xml file. As we all know, the Android interface is basically completed by the xml file, so the ListView interface should also use the xml definition. For example,
The adapters in life
Buy a laptop, buy a mobile phone, there is a power adapter, the power adapter is called external power supply, is a small portable electronic equipment and electrical power supply voltage conversion equipment, commonly used in mobile phones, notebook computers. Its role is to convert the home's 220V high voltage to these electronic products can work 5v~20v low voltage, so that they can
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.