This week’s IPM was cutting it close, but it did get done. The quick sort took me longer to implement than I expected which lead to me staying up until 2:30 last night. Which is rare these days now that I’m up at 6 a.m. every morning. This week doesn’t seem nearly as intimidating, and I think I can actually leave my chair every so often if I’d like.

My presentation this week (and also what this blog post is about) is component cohesion.

Component Cohesion

Component cohesion is a critical concept in software design that ensures the elements within a component work together as a single, focused unit. High cohesion leads to more maintainable, understandable, and reusable code, while low cohesion results in components that are harder to manage and evolve. To achieve this, three principles guide how we organize classes and modules into cohesive components: the Reuse/Release Equivalence Principle (REP), the Common Closure Principle (CCP), and the Common Reuse Principle (CRP).

Reuse/Release Equivalence Principle (REP)

The REP emphasizes that reusable components should be equivalent to releasable components. This means that if a component is reusable, it should be independently versioned and distributed, with clear boundaries for its responsibilities. By ensuring that reusable components are self-contained and follow a defined release cycle, REP helps maintain consistency and reliability across projects.

Common Closure Principle (CCP)

The CCP states that classes that change for the same reasons should be grouped together within the same component. By adhering to this principle, you minimize the ripple effect of changes, reducing the likelihood of bugs and maintenance headaches. It’s like keeping related items in the same kitchen drawer—you don’t want to scatter them across the kitchen, making it harder to find and update them.

Common Reuse Principle (CRP)

The CRP suggests that classes that are reused together should be part of the same component. When multiple classes are commonly reused as a group, bundling them together prevents unnecessary dependencies. Imagine a set of baking tools: if you always use the measuring cups, spoons, and mixing bowls together, storing them in the same drawer makes your workflow smoother and more efficient.

The power of Cohesion

When these three principles are applied, the resulting components are cohesive, stable, and easier to maintain. Each principle addresses a different aspect of cohesion—reusability, change management, and dependency control—leading to software that’s more reliable and adaptable to change.

By thoughtfully applying REP, CCP, and CRP, we create components that are not only cohesive but also align with the broader goals of good software design: simplicity, clarity, and maintainability.