What is cohesion in software development? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

What is cohesion in software development?

18th Aug 2019, 10:30 AM
Rajnish Kush
Rajnish Kush - avatar
2 Answers
+ 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?
19th Aug 2019, 1:49 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
can't understand
18th Aug 2019, 2:29 PM
Rajnish Kush
Rajnish Kush - avatar