What is high cohesion and low coupling.

Source: Internet
Author: User
First of all, this is what I saw on the Internet, and I don't remember the link. Cause: module independence means that each module only performs the independent sub-functions required by the system, and has the least contact with other modules and the interface is simple. There are two qualitative measurement standards: coupling and cohesion. Coupling is also called inter-block connection. A measure of the closeness between modules in the software system structure. The closer the relationship between modules, the stronger the coupling, and the poorer the module independence. The coupling between modules depends on the complexity of Inter-module interfaces, the call methods, and the information transmitted. Coupling classification (low-high): no direct coupling; Data coupling; tag coupling; control coupling; Public coupling; Content coupling; 1 no direct coupling: 2 Data coupling: it refers to the call relationship between two modules. It transmits simple data values, which is equivalent to value transfer in advanced languages. 3. Tag coupling: it refers to the data structure transmitted between two modules, for example, the array name, Record Name, and file name in the advanced language are marked. In fact, the address of the data structure is passed. 4. control coupling: when one module calls another module, A control variable (such as a switch or sign) is passed. The called module selectively executes a function in the block through the value of the control variable. 5 Public coupling: coupling between modules that interact with each other through a public data environment. Complexity of Public Coupling Program The number of Coupled modules increases. 6. Content coupling: this is the highest degree of coupling and the worst coupling. When one module directly uses the internal data of another module, or transfers the data to another module through an abnormal portal. Cohesion is also called intra-block contact. A measurement of the module's functional strength, that is, a measurement of the closeness of each element in a module. If the elements in a module (between language names and between program segments) are closely related, the higher the cohesion.
Consortium (low-high): Occasional cohesion; logical cohesion; time cohesion; Communication cohesion; sequential cohesion; function cohesion; 1 accidental cohesion: there is no connection between each processing element in a module. 2. Logical cohesion: it refers to the execution of several logical functions in the module, and the parameter is used to determine which function the module completes. 3. Time cohesion: Combine the actions to be executed at the same time to form a time cohesion module. 4. Communication cohesion: All processing elements in the module operate on the same data structure (sometimes called Information cohesion ), or, each processing process uses the same input data or generates the same output data. 5. Sequential cohesion: each processing element in a module is closely related to the same function and must be executed sequentially. The output of the former function element is the input of the next function element. 6. Function cohesion: This is the strongest cohesion. It means that all elements in the module work together to complete a function. Coupling with other modules is the weakest. Coupling and cohesion are two qualitative criteria for module independence. When dividing software systems into modules, we try our best to achieve high cohesion and low coupling, improve the independence of modules, and lay the foundation for designing high-quality software structures. An example is easy to understand: A program has 50 functions, and this program runs very well. However, once you modify one of the functions, all the other 49 functions need to be modified, this is the consequence of high coupling. Once you understand it, when writing a summary design, the design class or module will naturally consider "High Cohesion and low coupling ".

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.