What is cohesive Java?
Category:
technology and computing
programming languages
Cohesion in Java. In object oriented design, cohesion refers all about how a single class is designed. Cohesion is the Object Oriented principle most closely associated with making sure that a class is designed with a single, well-focused purpose. The more focused a class is, the cohesiveness of that class is more.
Accordingly, what is cohesion explain with example?
Cohesion means sticking together. If your group of friends heads to the lunchroom as a team and sits all together, you're demonstrating strong cohesion. Cohesion is a word that comes to us through physics, where cohesion describes particles that are the same and tend to stick together — water molecules, for example.
In this regard, what are the pros of a high cohesive class?
Advantages of high cohesion (or "strong cohesion") are:
- Reduced module complexity (they are simpler, having fewer operations).
- Increased system maintainability, because logical changes in the domain affect fewer modules, and because changes in one module require fewer changes in other modules.
cohesion: degree of well defined definite purpose of a class. low cohesion means a class has varied purpose of existence. high cohesion means a well defined definite purpose of existence. coupling is a degree in which one class knows about the other class.