What is the idea of Java coding for high cohesion and low coupling?

Source: Internet
Author: User

Describes the internal characteristics of the module, and the external reference relationship of the module.



Cohesion is the degree to which each element in a module is tightly bound to each other, and high cohesion is a module in which each element is tightly bound to each other.

Cohesion is in terms of the internal characteristics of any of these modules.

Coupling is the correlation of the various modules in a system consisting of multiple modules.

High cohesion is to say that the inside of the module to be highly aggregated, low coupling is to say that the coupling between modules and modules should be as low as possible. The former refers to the internal relationship of the module, the latter is the relationship between module and module.



Cause: module independence means that each module accomplishes only the individual sub-functions required by the system, and has a minimum of contact with other modules and simple interfaces, two qualitative metrics-coupling and cohesion.

Coupling is also known as inter-block linkage. A measure of the degree of connection between modules in a software system structure.The tighter the connection between the modules, the stronger the couplingThe module's independence is worse.The coupling between modules depends on the complexity of the interface between modules, the mode of invocation and the information transmitted.



Coupling and cohesion are the two qualitative standards of module independence, when the software system is divided into modules, it is possible to achieve high cohesion and low coupling, improve the independence of modules, and lay the foundation for designing high quality software structure.
One example is easy to understand: A program has 50 functions, the program executes very well, but once you modify one of the functions, the other 49 functions need to be modified, which is the consequence of high coupling.
Once you understand it, the design class or module will naturally take into account "high cohesion, low coupling" When you write an outline design. 

What is the idea of Java coding for high cohesion and low coupling?

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.