Coupling | Cohesion — [Notes]

Tarun Jain
3 min readNov 24, 2022

--

[Refer LLD Index for all LLD topics]

**Please read the article in its entirety, and if you’re inquisitive and want to dig deeper, click on any of the sources listed in this article.

**These are notes that I’m making for myself. I have cited the source for an image or piece of content, and all sources are listed again at the end of the article. Please read the sources to get the most out of this essay.

Coupling

“degree of interdependence between software modules

Cohesion

“degree to which the elements inside a module belong together” — Structured Design: Fundamentals of a Discipline of Computer Program and Systems Design

Functional Cohesion / Capability Centric

  • Grouped related to operations of a task.

Single Responsibility Principle

  • When you write a software module, you want to make sure that when changes are requested, those changes can only originate from a single person, or rather, a single tightly coupled group of people representing a single narrowly defined business function.
  • You want to isolate your modules from the complexities of the organization as a whole, and design your systems such that each module is responsible (responds to) the needs of just that one business function.
    source — https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html

Informational Cohesion / Entity Centric

  • Can drive high degree of coupling.
  • Focus will be on data instead of functional boundary
One product entity dealing everything about the product. Will result in high coupling as Warehouse, Sales, Purchasing will need this entity service data

vs

Capability centric design

Why low level code is organized by technical concerns?

MVC — Model + View + Controller | generally each one of them has 1:1 mapping with each other

MVC approach. Source — https://youtu.be/YDNR_gfBk0Q

vs
Organize by Feature

Organized by feature. Source — https://youtu.be/YDNR_gfBk0Q

How to handle coupling between highly cohesive services?

Async messaging to tackle coupling

How to handle coupling between mixed responsibility in code?

  • Can use Pipes and Filters pattern [Russian Doll]
Source — https://youtu.be/YDNR_gfBk0Q

References

--

--