From a higher level, the design model is actually the scope of methodology. For the popular software design model, the starting point of its introduction is mostly at the programming level. the design pattern itself belongs to the methodology layer and is summarized by people in the process of cognition and transformation of the real world. Therefore, these methods are either in software design or hardware design, even designs in other fields are applicable to interdisciplinary and cross-domain methodologies.
The relationship between objects in the real world is very complex. In a four-dimensional space, the relationships between objects can be simply divided into static and dynamic relationships (here, the four dimensions refer to three-dimensional space + one-dimensional time ), static relationships express the locations between objects (in a four-dimensional space), while dynamic relationships express the interaction (behavior, communication) between objects ), the indirect method discussed today is a simple and simple method to process the dynamic relationship between objects. because the interaction between objects is very complex, the direct interaction (Communication) between objects is very difficult (inaccessible, expensive, and too complex ), you can add an auxiliary object (third-party, which can exist naturally or be manually added) Among these objects to achieve communication purposes. This method is an indirect method, the third party in the indirect method is called an intermediate role. Note that the intermediate role can be an object or a site ". indirect Method scenarios and processing methods are everywhere in the real world, such as currency, market, agent, and bank. in addition, this indirect method has multiple and relative characteristics. Multiple means that the intermediate role can be either lateral or vertical. relativity means that the intermediate role is relative, for example, in a-> B-> C, B is an intermediate role, but in B-> C-> D, B is a communication party role. of course, in the actual system design, we should avoid multiple roles as much as possible, so that the object responsibility should be as single as possible.
The indirect method not only makes the role of Objects Possible (for example, the phone number allows two people who are far away to talk), but also provides great flexibility and reduces costs (supermarkets, markets, etc ). most of the creation and behavior types in the software design model belong to the category of indirect method, and many of the structure types are also the embodiment of this method. the indirect method tells us that if:
A) It is difficult to directly process one task (Inter-object communication );
B) if the processing capability of an object is limited (too many responsibilities); (in terms of methodology, this tends to be an auxiliary method)
C) to be more flexible and scalable
......
We can try to add some intermediate roles to assist in processing. It should be noted that, from the perspective of role decomposition, some intermediate roles are not "intermediate", which does not matter.
1) make the role possible (to solve the fundamental problem );
2) provides flexibility and scalability;
In actual processing, it is relatively easy to set intermediate roles when using the indirect method. But how can we deal with the responsibility relationship between the original object and the intermediate object? The method is to re-allocate the responsibility, and the principle is to have a single responsibility. responsibility sheet is a simplified method. next, let's take a look at the indirect method application in the software design model: the purpose of creating a model design model is to reduce the responsibility for creating consumer objects (Object users, at the same time, the create responsibility is centralized to obtain certain control functions, so as to facilitate the addition and expansion of the create responsibility. the indirect method is used to add an intermediate role-object factory, which is responsible for creating product objects. in this mode, the interaction objects are divided into three roles: Products, factories and consumers. this mode is consistent with the processing method of most product production and consumption in our real society.
Proxy, observer, and command modes are typical applications of indirect methods. it should be noted that these models are not specific to software design. These methods are summarized in real production and life.
PS: writing this article is very brain-consuming.