The Use Of The Adapter
Adapter is something we are familiar with, but when seriously think about what the adapter in the end, we may really can not tell why, today, please follow Xiaobian together to understand the adapter.
The adapter is English translation of the Adapter / adaptor. The adapter is an interface converter, which can be a separate hardware interface device that allows hardware or electronic interfaces to be connected to other hardware or electronic interfaces or to an information interface. For example: adapter, Adapter tripod base adapter parts, USB and serial port transfer equipment.
In a computer, the adapter is usually built into a card that can be plugged into a slot on the motherboard (and also an external) card to exchange information between the adapter and the device supported by the processor and the adapter.
The adapter is a small portable electronic equipment and electrical and electronic power supply conversion equipment, generally by the shell, power transformer and rectifier circuit, Adapter according to its output type can be divided into AC output type and DC output type; according to the connection can be divided into wall And desktop. The mobile PC is particularly important because there is no battery.
Most mobile PC adapters can automatically detect 100 ~ 240V AC (50 / 60Hz). Basically all the mobile PC power supply external, with a line and the host connection, which can reduce the size and weight of the host, only a very small number of models built-in power in the host. There is a nameplate on the adapter, Adapter which indicates the power, input and output voltage and current and other indicators, with particular attention to the input voltage range, which is the so-called "travel adapter."
When an MBean is registered to an MBean server, a protocol is required to interact with these MBeans and retrieve information for requests from the management application. This is enabled through a protocol adapter that converts management application data into standard protocol information.
Multiprotocol Agent supports protocol adapters including: SNMP, TL1, RMI, CORBA, HTTP, and HTML adapters.
In the actual development process, we often encounter such a thing, Adapter we according to the initial needs of the development of a base class, in the development process to understand the detailed needs or demand has changed. And the development of the interface has long been defined, Adapter and has been large-scale input coding. At this point if the definition of changes in the interface will cause a lot of coding on the repetitive modification of the work, and thus may cause incomplete changes caused by semantic errors or logic errors. Semantic errors can still be found in the compilation phase, and in the event of a logical error, the consequences will be very serious, even enough to cause the system to crash. At this point you need to use the adapter model design method.
In computer programming, the adapter pattern (sometimes also called the wrapper style or wrapper) adapts a class of interfaces to what the user expects. An adaptation allows classes that are usually not compatible with the interface that are not working together, Adapter by wrapping their own interfaces in an existing class.
The adapter pattern is mainly used when the method defined in the interface can not meet the needs of the customer, or the name of the method defined in the interface or the interface of the method conflict with the customer's needs.
How to use the adapter mode:
Using a class to inherit the interface and the known class at the same time, use the methods and properties defined in the known class to implement the definition of the interface (mainly using the method of overloading the interface method). Use this class as the base class for other business classes, that is, Adapter this class fits the interface and the known class. If the known class changes, just modify the class adapter, you can meet the interface implementation.