Talking about the significance of decoupling --- we are always pursuing decoupling, but we don't know where it is ,---

Source: Internet
Author: User

Talking about the significance of decoupling --- we are always pursuing decoupling, but we don't know where it is ,---

When talking about decoupling, we need to mention the design mode. The design mode comes from the analysis mode. The design mode is the concrete expression of the analysis mode.
For example, we buy a large item like a refrigerator.

From an objective point of view, this kind of thing is not taken directly, so we simplify this process: You choose the refrigerator, give money, then the salesperson generates orders for you, the deliverer delivers goods. If we choose refrigerator, place an order for payment, and set the delivery period as pink time, then the salespersons, deliverers, and customers involved in the process will be green, for example, when the clerk collects money, the clerk has the permission to operate the financial table from the data perspective. The order is the permission to operate the order table, which is yellow, in the domain model, green in the objective world gives the yellow color to perform operations during the pink period. ObjectiveSummaryUpSpecified person with the specified permission to perform the specified operation

From the perspective of three layers, we have data tables, user tables, order tables, shipping tables, and so on. What is the separation between the data layer and the Business Layer? Is this shopping example, for example, the clerk collects money and generates orders for the clerk.Operation data, ThenData LayerTake this part of work away. The rest is,Where did the salesman come from?Collect money and operate FinancePermission? How can a salesman know who wants to buy (Who are participants)? These are handed overLogic layer.

Encapsulate different responsibilities into different classes or modulesIsn't it one of the basic principles of object-oriented (Single Responsibility Principle). However, when we use the abstract factory design pattern, we reduceDependencyRelationship, the creation object depends on the factory class and a setAbstract Interface,Dependency inversionThe core idea isAbstraction.The upper-layer module calls the interface and implements the lower-layer module.Interface.

Here is the decoupling process.MeaningWhat about it?

Just like a person in our development process, from the front-end to the back-end to the maintenance, to the full management of the database, it is better to work in a division of labor, the less internal contact, the more stable a system, as the saying goes, one more thing is better than one less thing. Actually speaking: the business will change, but database operations will end with those methods. When the business changes, we do not need to change the data layer. Even if a new data layer method is required, you only need to add a method without changing the old code of the business layer. What we said just now seems to be the benefit of division of labor? In fact,Layer 3 is a decoupled architecture.The three layers are also generated for scalability, but we still need to continue to use various modes for decoupling. We can only infinitely reduce coupling, but cannot eradicate them, this is because the relationship is lost.Open and closedPrinciplesSaid: software entities (classes, modules, methods, etc.) should be extensible, meaning that the functions of software modules can be changed. However, while expanding new functions, you do not need to modify the original code, it does not affect the original code. How can it be opened and closed? OrAbstraction.Abstract things are stable and do not need to be modified. abstract things can be embodied into different instances for extension.

China dreamIt is a good object-oriented design.

China dreamScalable: It can be expanded to the Chinese dream of farmers (with their own land), the Chinese dream of businessmen (with prosperous business), and the Chinese dream of athletes (to be the champion)

China dreamVery stable: Although dreams differ widely, they can all be attributed to the unchanging Chinese dream. DreamBase ClassNever changed.

 

Related Article

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.