Cohesion in C#

王林
Release: 2023-09-10 18:25:02
forward
1082 people have browsed it

C# 中的内聚性

Cohesion in C# shows the relationship between modules. It shows the functional strength of the module. The higher the cohesion, the better the program design.

It is a dependency between elements inside a module (such as methods and internal modules). High cohesion will allow you to reuse classes and methods.

An example of high cohesion can be seen in the System.Math class, i.e. it has mathematical constants and static methods -

Math.Abs
Math.PI
Math.Pow
Copy after login

Classes that do many things at the same time are difficult to understand and maintain. This is what we call low cohesion and should be avoided. If a class will provide email, printing, copying, etc. functionality, it will be difficult to maintain and reuse.

Always try to achieve strong i.e. high cohesion in your code.

The above is the detailed content of Cohesion in C#. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template