Junior — Middle
Can you explain what is meant by cohesion in the context of software systems?
sobes.tech AI
Answer from AI
Cohesion in software systems is a measure of how closely related and focused the elements within a module or class are, working together to perform a single task. High cohesion means that all parts of the module are strongly related and aimed at executing a single function, which improves readability, maintainability, and reusability of the code.
For example, a highly cohesive class will have methods and properties that all relate to a single responsibility. If cohesion is low, it means that different tasks are mixed within the same module, making maintenance and testing more difficult.