in the previous blog post. Together we learned about the situation of the creation pattern group, and let's look at the situation of the structure pattern of the "death group". The so-called structural model is designed for the structure of the system, focusing on the structure of the product hierarchy and so on.
Let's take a look at the information about each of the various portals in this group:
Adapter mode: The interface of a class is transformed into another interface that the customer wants. The adapter mode makes it possible for those classes that would otherwise not work together because of incompatible interfaces.
Bridging mode: Separates the abstract part from its implementation, enabling them to change independently.
Composition mode: Combines objects into a tree structure to represent a "partial-overall" hierarchy, combining patterns that allow users to be consistent with the use of individual objects and composite objects.
Decorating mode: Dynamically adds some additional responsibilities to an object, and in addition, the adornment mode is more flexible than generating subclasses.
Appearance mode: Provides a consistent interface for a set of interfaces in a subsystem. The appearance mode defines a high-level interface, which makes the system easier to use.
Enjoy meta-mode: effectively supports a large number of fine-grained objects for the execution of shared technologies.
Proxy mode: Provides a proxy for other objects to control access to this object.
All right, all the doors are on the stage and the war is on. We wait and see:
The first thing to do is adapter mode: in the real world. Change is everywhere. Object-oriented appearance is to better respond to changes in demand. Suppose, however, that you want to use a class that already exists, and that its interface does not meet the requirements. Or would you like to create a reusable class that can work with other unrelated classes or classes that are not predictable? Hahaha ... We can do this by making the different classes of these interfaces work together after they are adapted.
Active attack effect is uncommon, bridging mode take: face change. Object-oriented inheritance is really good, but over-use, it is bound to cause the structure of the class is too complex, the relationship is too dense, difficult to maintain. Even more deadly is the very poor extensibility.
And we can study the integration system, assuming that there are two or even multiple directions of the changes, then decoupling these changes in different directions. Through the combination of objects, the inheritance relationship between the two characters is changed to the combined relationship. So that the two can cope with their own independent changes. What's up, huh?
Decoration mode is the women's door, although for the Guorui. But there is no fear: in the face of change, it is assumed that the method of generating subclasses is used to augment, in order to support the combination of each extension, a large number of subclasses will be produced. There are too many subclasses, but in fact these subclasses simply add some responsibility to an object. At this time by decorating the way. To be more flexible, dynamic, transparent to the individual objects to join the responsibility, and when not necessary, revoke the corresponding responsibilities.
Combination mode Once you look at this posture, you have to use your own skill: we are good at representing the object's part and the overall hierarchy, and I want the user to ignore the difference between the combined object and the individual object. Users are able to use all objects in a composite structure uniformly.
The user interacts with the objects in the composite structure using the combined class interface, assuming that the recipient is a leaf node and is processed directly. The assumption is a composite object. A request is typically sent to its child parts, and some secondary actions may be run before or after forwarding, with the effect that the customer can use the composite structure and individual objects in the same way. Combining objects can be used wherever they are used in the base object.
Appearance mode According to endure, shout a sound, volley up: the weaker the coupling between the classes, the more beneficial to reuse. Assuming that two classes do not have to deal directly with each other, then do not let these two classes have direct interaction, if necessary, can use a third party to forward the call. Our unique unique knowledge is the introduction of a façade object that provides a single, simple barrier between subsystems. Usually the three-layer or N-layer architecture of enterprise software, the separation between layer and layer is actually the embodiment of the appearance pattern.
Enjoy meta mode, outraged, yell, let me try: objects make memory consumption too much. and assume that it is a large number of repeated objects. That is a huge waste of resources that can slow down the performance of the machine. Object-oriented technology can sometimes be very expensive for simple design, such as document processing software. The characters can be objects, assuming that each character in the document is a character object, the overhead is humiliating.
While the characters in the document are nothing more than writing symbols, we let all the same symbols share an object, such as all "a" sharing a "a" object. Save memory.
Proxy mode go straight to the point of view and the direction of the adapter mode. The difference between agent and appearance is that the proxy object represents a subsystem on behalf of a single object. The agent's client object cannot directly access the target object, and the agent provides access control to the individual target object. But the appearance of the client object can directly access the subsystem of the individual objects, but usually by the appearance of the object to provide sub-system components function of a simplified common level of the call interface. As for me and the adapter, in fact all belong to a cohesive nature function. An agent is a representation of an original object, and other operations that need to deal with this object are negotiated with this representative. The adapter does not need to invent a representative, just need to be used for specific purposes, the original class to some combination.
Finally the appearance mode has made the powerful three-point return vitality, immediately weeping. Flying debris: Bridging and adapters are used at different stages of the software lifecycle, and there is no point in addressing different issues. And I have some approximation to the adapter, which is the encapsulation of the existing system. I think it's inappropriate for someone to say I'm an adapter for another set of objects. Since I am defining a new interface, the adapter is reusing an existing interface. The adapter is working with two existing interfaces, and I am providing a more accessible interface to the existing system.
Assuming that I am a fit, I can only say that the adaptation is used to match the object, and I am using it to fit the whole system. Who is more powerful, discerning eye can see.
After the Guild Wars. Ruins, a mess, but the winner has only one:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbglhbmppyw5nd2vp/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
Who is the Overlord in object-oriented design? In