Sobes.tech
Junior — Middle

How do the concepts of module internal cohesion and the degree of interconnection between modules in a system differ?

sobes.tech AI

Answer from AI

Cohesion within a module refers to how logically related and interconnected the elements inside a single module (functions, classes, methods) are, working together to perform a single task. High cohesion means that the module is responsible for one specific function or a set of closely related functions, which simplifies understanding and maintenance.

Coupling between modules is the degree of dependency one module has on another. Low coupling indicates that modules are loosely connected and can change independently, increasing flexibility and easing system scaling.

In summary:

  • High cohesion within a module is good.
  • Low coupling between modules is good.

Example: In C#, a class that is responsible only for database operations (high cohesion) should not directly depend on the UI module (low coupling).