Wednesday, April 5, 2023

Component Cohesion


Component Cohesion

Component Cohesion refers to the degree to which the elements of a component or module are related and work together to achieve a single purpose or responsibility. There are different types of cohesion, such as functional cohesion, sequential cohesion, communicational cohesion, etc. High cohesion is desirable as it leads to a more maintainable, testable, and reusable codebase.

The Reuse/Release Equivalence Principle (REP)

The Reuse/Release Equivalence Principle (REP) states that the granularity of a software component's reuse should be the same as its release. In other words, a component that is released and versioned as a single unit should also be reused as a single unit. This principle ensures that changes to a component do not affect other components that depend on it.

The Common Closure Principle (CCP)

The Common Closure Principle states that classes that change together should be packaged together in the same component. This principle ensures that changes to a component are minimized and that the component can be easily maintained and evolved. CCP is closely related to the Single Responsibility Principle (SRP) and the Open-Closed Principle (OCP).

The Common Reuse Principle (CRP)

The Common Reuse Principle (CRP) states that classes that are used together should be packaged together in the same component. This principle ensures that components are reusable and that the reuse of a component is not limited by other components it depends on.

The Tension Diagram for Component Cohesion is a tool for analyzing and visualizing the cohesion of software components. It consists of a two-dimensional graph that plots the degree of functional cohesion against the degree of coincidental cohesion. Functional cohesion refers to the degree to which the elements of a component are related and work together to achieve a single purpose or responsibility, while coincidental cohesion refers to the degree to which the elements of a component are related by chance or coincidence. The tension between these two types of cohesion can help identify areas where a component can be improved.

No comments:

Post a Comment

LeetCode C++ Cheat Sheet June

🎯 Core Patterns & Representative Questions 1. Arrays & Hashing Two Sum – hash map → O(n) Contains Duplicate , Product of A...