Different Types of Cohesion in Object-Oriented Systems

What are the three general types of cohesion in object-oriented systems? The three general types of cohesion in object-oriented systems are method, class, and generalization/specialization.

When it comes to object-oriented systems, cohesion plays a crucial role in determining how well elements within a module are related to each other. It can be seen as the internal adhesive that holds modules together, with high cohesion indicating well-structured software.

Method and class cohesion are two types that help hold modules together by focusing on responsibilities and relationships within and between classes. On the other hand, generalization/specialization deals with identifying common features among classes and grouping them into a superclass for easier management.

It is essential to strive for high cohesion in software design to ensure that each module has a single responsibility and is easier to maintain and debug. While inheritance can introduce multiple responsibilities, other composition techniques like generalization, specialization, association, and aggregation can be used to promote code reuse without relying on inheritance.

In the realm of object-oriented programming, multiple inheritances are not supported in most languages due to the challenges they present in maintaining high cohesion. As a result, the three primary types of cohesion—method, class, and generalization/specialization—play a key role in keeping object-oriented systems organized and efficient.

← How to manage your aws account root user credentials Understanding the relationship between workbook and worksheet →