Design patterns and system structures

Source: Internet
Author: User

Original address: http://www.jdon.com/46774

We often encounter a problem: Mother and wife fall into the water, you first save Which? This question is difficult to answer, we dissect this problem from the angle of GOF design pattern and system.

Gof design patterns are divided into three types: structural, creation and behavioral, which correspond to the three stages of a system: the design phase, the creation phase, and the operational phase.

The structure pattern indicates how to design the structure of the system, that is, the gestation of a system, as the process of human being conceived.

The creation pattern indicates how the system was initially created, that is, the moment before the Big Bang, when the system landed on paper, like the birth and upbringing of a person, and was created from scratch.

The behavioral pattern is to go into the self-running phase after the system is created, and no need to intervene with the creator or designer, as the adult marries the child. Which is the state of operation after the formation of the universe.

Here's a concrete demonstration:
(1) The structure mode has facade Proxy Bridge mode adapter adapter and combination mode, and so on, these patterns common to the code structure of how to design, such as adapter mode is designed to be a suitable class, can be the original two mismatched classes can be harmonized, the structure may have three classes, General structural relationships can be expressed using UML class diagrams, which is a combination of code structures that combine two of classes, which is a constituent structure relationship.

Structure is related, this is why the relational database can express the structure, the design table structure schema is actually the design structure relationship.

In the field of architecture, the design of civil structures requires a precise design phase, and architectural drawing is a structural or architectural design, similar to our structural model.

(2) The creation mode has the Factory mode, etc., the creation pattern points out how a system can be created from the design drawing to the landing, just as a building needs to be built from the drawing to the completion of the construction process. The factory model indicates that there is a factory class responsible for creating the class.

(3) The behavioral mode has the command responsibility chain observer and so on, these modes are for the system to enter the self-run phase, the internal system how to run, such as the command mode refers to the request from the client package into a command, the back end according to the command to assign the corresponding module response processing. And the responsibility chain is similar to the filter, can filter the request command to intercept, the Observer mode is a timely response to the state change of the runtime, to the later reactor mode or asynchronous mode, becauseAsynchronous Programmingis for the system operation phase of programming, coding needs to associate with the state of the system operation, which is not a system operating experience of the programmer is more difficult, the general programmer is more suitable for sequential programming, sequential programming is a structural programming, then we provide some framework for sequential programming code to run asynchronously, These are developments that have been realized at different stages of the system.

Therefore, recognizing that a system has different logical boundaries is more important to our understanding of the world, the structural design, creation and operation stages of the system are three strictly different logical worlds, just as the three realms of heaven and hell are different.

With the understanding of the system boundary, it is very easy to answer the question of the beginning of this article, which the mother and wife drop water to save? Mother is to create self-rearing, and the wife is their own adult into the life stage of the focus, the mother belongs to the founder, is the focus of the creation phase, and the wife is the focus of the operation phase, the two key cross-domain boundary comparison is clearly not logical, the person who raises this question does not have a system logic demarcation.

Another example: Boss big or company rules and regulations big? The boss is indeed the company system, the actual founder of the establishment stage, but once the system promulgated, into the operational stage, the boss himself must obey the system management, this is a big system.

There is also an economic problem, an important two role in the economy, a commodity needs producers and consumers, so producers are important or consumers important? In the past planned economy period, we seize the production, the results of economic still did not catch up, state-owned manufacturers are closed, in fact, not from the system stage boundary to understand the problem, the producer belongs to the economic system to create the stage of the eldest, only a large number of production plants to create a variety of goods But when the economy enters from the operational stage, the oversupply, the economy will collapse, then the consumer is the eldest, only consumption is the key to drive the economy, which is also the core of economic theory such as Keynes, that is why the western countries to encourage early consumption of the logical basis of loans.

Pull so many salted eggs, mainly to explain, in fact, design mode is not only for programming has a role, but also for their own three views are helpful, because the developer developed a software system, the perfectly formed, the basic principle of God to create the world. If a programmer only knows the data structure and algorithm, but does not have the basic logic understanding to the stage of the design creation and the running of a system, then obviously loses in the detail to lose the direction.

From Lao Tzu's Philosophical Point of view: The data structure algorithm and function belong to "have", can see touch, and the system stage boundary belongs to "none", although the invisible State, but the natural way is no life has, we can not because the first learning the tangible knowledge, but neglected the intangible thought.

Design patterns and system structures

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.