Cohesion and coupling
Low cohesion and high cohesion, along with tight coupling and loose coupling, are important concepts in software engineering that have a direct impact on the quality and maintainability of code. Let’s explore these concepts in the context of C# and how they can affect the quality of your code:
- Low cohesion:
- Low cohesion refers to a situation where a class or module has too many responsibilities, or its functions and methods are not closely related to each other
- In C#, low cohesion can result in classes that are difficult to understand and maintain, as they perform various unrelated tasks
- This can lead to code that is more error-prone, harder to test, and challenging to extend or modify
- High cohesion:
- High cohesion means that a class or module has a well-defined and focused set of responsibilities, and its methods and functions are closely related to those responsibilities
- In C#, high cohesion results in code that is easier to understand, maintain...