Glossary · Automation software engineering and architecture
Cohesion
Also known as: Module cohesion
German: Kohäsion
In software engineering, cohesion is the degree to which the elements inside a module or component belong together and serve a single, well-defined purpose. High cohesion makes modules easier to understand, test, reuse and change.
- Software engineering
In one sentence
Cohesion is the degree to which the elements inside a software module belong together and serve a single, well-defined purpose.
Example
A function block that handles only the gripper's open, close and feedback logic has high cohesion; one that also calculates OEE and formats HMI texts does not.
How it applies
- Engineering: Aim for modules that do one thing. In PLC programs, equipment-oriented structures, such as one function block per device type, naturally support cohesion.
- Reviews: Signs of low cohesion include generic 'utility' blocks, functions with many unrelated parameters and names that need 'and' to describe them. Splitting such modules usually reduces the impact of later changes.
- Documentation: A cohesive module can be described in one or two sentences, which is a useful test in itself. If the documentation team struggles to explain what a module is for, the design may need attention.
Cohesion vs. coupling
Cohesion looks inside a module; Coupling looks at the dependencies between modules. The usual design goal is high cohesion and Loose coupling: related things together, unrelated things independent. The two are connected, because moving a responsibility into the right module often reduces coupling at the same time.
Not to be confused with Coupling analysis in systems engineering, which examines interactions between system elements.