This talk mesmerised me on the factual analysis of complexity and modularity. Two concepts that for many architects and engineers may seem subjective or ephemeral.
Coupling
Vlad wonderfully captures the concepts of Integration Strength and Coupling Distance to highlight an objective frame for determining high coupling and high cohesion. You no doubt heard of this concept via SOLID principles or Clean Code.
If you check my conversation with Milan Jovanović on the Technologist Podcast, you may recall our Clean Architecture bingo.
Where something belongs and what it should or should not be coupled to can be derived with a simple formula. At least so claims Khononov:
Modularity = Strength xor Distance (M = S ^ D)
S stands for Integration Strength
D stands for Coupling Distance
M is modularity
The XOR denotes we don’t want them both to be high at the same time.
Ie. a module should be Strongly integrated and have low distance from other components or Loosely integrated and have high distance to other concerns, but never both.
Both are high? Lower distance
Both are low? Increase distance
Given a typical example of non-aggregate repository abuse with a framework and ORM, here are a few examples of typical choices (strength/distance, preferred ones bold, L meaning low, H meaning high):
L/L: Generic Kind of Repository + Generic Kind of Entity + Generic Adapters everywhere
L/H: The Repo is Concrete to the Aggregate/Entity - it is reversing abstraction towards query mechanisms and ORM infrastructure ← use dependency injection to further decouple model from infrastructure code
H/L: The Repo is Concrete towards the types of Queries - abstraction is reversed towards factory methods that create lazy, full or partial models ← One of them is an abstract, fully functional “Base Model”
H/H: The Nightmare scenario, everything is in one giant file, including the autogenerated, autowired code from the application framework and ORM.
👆 I know you have many questions
… but today is about the video. Tomorrow, we’ll follow up on some common DDD questions and pitfalls from the community.
Enjoy the video.