+ 5
What is cohesion in software development?
4 ответов
+ 5
Let's say you have a few balls with different colours.
High cohesion is about putting balls with the same colour into their own boxes. So we have purple balls in one box, green balls in one box etc. In the case of low cohesion, we'd see that balls of different colours are scattered across the boxes.
Now think of these balls as classes and methods. Balls with same colour would be classes and methods which serve the same purpose. The practice of high cohesion would be to put classes, methods, constructs, etc which serve the same purpose, together. We do this by grouping them into the same module, submodule, etc.
A bit of exercise: Now can you imagine what would happen in the case of low cohesion? How would you define cohesion in your own words?
+ 5
can't understand