What does 'High Cohesion' mean for a class, and why is it desirable?
Last updated
High cohesion means all of a class's data and methods serve one well-defined responsibility. You can name its purpose in one sentence without "and".
It makes classes easier to understand, keeps changes localised, and improves reuse and testability. A "god class" mixing unrelated jobs is the opposite.
High cohesion tends to produce loose coupling and aligns with the Single Responsibility Principle.
- https://www.igmguru.com/blog/oops-interview-questions
- https://tryrehearsal.ai/technical-questions/explain-oops-concepts
- https://github.com/Devinterview-io/oop-interview-questions
- https://www.hirist.tech/blog/top-30-c-oops-interview-questions-and-answers/
- https://www.interviewbit.com/oops-interview-questions/
- https://blog.stackademic.com/dont-just-code-the-15-essential-practices-senior-developers-want-you-to-learn-now-84246fb2f6ed
- https://www.reddit.com/r/ExperiencedDevs/comments/1mpaewh/how_should_i_deal_with_junior_devs_that_debate/
- https://www.scaler.com/topics/oops-concepts-in-cpp/
- https://javatechonline.com/interview-questions-object-oriented-programming/
- https://henko.net/blog/my-favorite-interview-questions/
- https://utkrusht.ai/blog/python-interview-questions
- https://www.digitalocean.com/community/tutorials/oops-interview-questions-answers
- https://www.scribd.com/document/510810151/Fragile-base-class