Why High Cohesion and low coupling?

Source: Internet
Author: User

First of all, I think it is necessary to declare that high cohesion and low coupling are based on the object-oriented concept. Therefore, it is not easy to understand the basic idea of High Cohesion and low coupling. However, most articles and blogs on the Internet only talk about high cohesion and low coupling with high cohesion and low coupling. This blog attempts to talk about high cohesion and low coupling based on the object-oriented thinking to see if it is easy to understand.

The so-called cohesion refers to the relationship between each part of the module, which is expressed in seven levels.

Coupling refers to the relationship between modules, which is expressed in seven levels.

We all know that high cohesion and low coupling are important criteria for measuring the quality of software. Why?

First, object-oriented features are encapsulation, inheritance, and polymorphism. In essence, it is to abstract the originally chaotic code as much as possible into commonalities, and classify them separately. Ultimately achieve reuse, improve development efficiency and ensure software quality. As we all know, spider uses the Web to capture insects, because each node in the Web is interconnected with each other, which increases the toughness of spider networks and is not easily broken through by insects. The object-oriented approach is to reuse code and ensure stable operation, that is, to reduce connections between modules. As you can imagine, it is not easy to reuse code if the links between modules are too close, because it is difficult to find the same suitable environment. At the same time, it is also unfavorable for the operation, and software errors are inevitable. If the modules are closely connected, the system will trigger one error, like dominoes. Therefore, the relationship between a good software module cannot be too close, that is, low coupling.

The object-oriented thinking pursues a single kinetic energy for each module. The more independent modules, the better. That is, when dividing a module, only the elements of a function are divided into one module. Therefore, each element in the module must be closely related. Otherwise, it indicates that the module division is not in place. Therefore, the module must be closely connected, that is, high cohesion.

I don't know why high cohesion and low coupling are software quality standards!

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.