Structural model 2004-11-26
Adapter mode
Name: Adapter mode, wrapper mode
problem:
Suppose a graphic editor, manipulating graphics, such as LineShape, Polygonshape, etc. It is also a pity.
solve:
Define a TextShape class so that you can use it in the editor using LineShape, etc.
effect:
Solve the original incompatible interface can be converted via an adapter.
Adapter mode has two categories:
Class is the device, ready, Textshape, implement the Shape interface and use the TextView implementation
The object adapter uses TextView as a class of the class, and then implements TextShape with the interface of TextView.
Photo:
Bridge mode
Name: Bridge mode, Handle / Body mode
problem:
Considering the implementation of a portable Window abstraction section, allowing you to implement abstraction in your MS Windows and X Windows platforms, we allow you to implement abstraction in your respective platforms. If the inheritance abstraction, the abstraction of the extension is inconvenient. Also related to the platform code of the customer.
solve:
The operation of Window abstraction and its subclass is implemented in a separate layer, one of which is separately related to the Window interface separately, and another implementation of the platform. Sub-class operations for Window are all performed through the platform-related code. These two layers have realized bridges.
effect:
Separate interface and its implementation (such as JDBC driver)
Provide expandability
Details transparent to users
Photo: