Hiding The Lead: Coupling, cohesion and microservices
The document discusses the principles of microservices architecture as articulated by Sam Newman, emphasizing the importance of information hiding, independent deployability, and managing coupling and cohesion among modules. It highlights the need for explicit contracts and schemas to define module boundaries and minimize assumptions between them, thereby facilitating easier changes without breaking dependencies. Lastly, it underscores that low coupling and strong cohesion are crucial for achieving independent deployability in microservices.
Introduction to hiding the lead in coupling, cohesion, and microservices. Discusses independent deployability of services like Inventory and Shipping.
Focus on modules and their structure for independent and reusable working. Importance of module communication through network calls.
Legislation of information hiding to define module boundaries, the importance of maintaining internal implementation secrecy.
Explains accidental breakage in code due to unclear definitions and changing dependencies within modules.
Definition of Data Transfer Objects (DTOs) and their role in reducing dependencies and facilitating data operations.
Discussion on connections between modules, based on assumptions, and importance of explicit contracts to reduce dependencies.
Use of schemas for compatibility checking and promoting better testing practices in microservices design.
Defines coupling and cohesion, emphasizing their roles in module interactions and system stability.
Various types of coupling: domain, common, and content coupling. Discusses implications on information hiding and service flexibility.Reinforces the importance of information hiding, types of coupling, and strong cohesion for effective independent deployability.
@samnewman
AND MICROSERVICES?
Module A
ModuleDModule B
Module C
Module E
Communication
between
modules is done
via network calls
“Modules” run on different
computers
Allows for easier
independent deployability
@samnewman
AND CONNECTIONS BETWEENTHEM?
“The connections between
modules are the assumptions
which the modules make
about each other.”
- David Parnas
53.
@samnewman
AND CONNECTIONS BETWEENTHEM?
“The connections between
modules are the assumptions
which the modules make
about each other.”
- David Parnas
Information hiding is about
reducing the assumptions
one module has for another
@samnewman
EXPLICIT CONTRACTS?
Module DModuleB
Need an explicit understanding of
the assumptions of consumers
To help us understand what can
change easily, and what cannot
Schemas can help!
@samnewman
CONTENT COUPLING
Order IDStatus
123 PLACED
456 SHIPPED
WarehouseOrder Processor
Information hiding bypassed
Unclear what can safely be
changed in the Order service
107.
@samnewman
CONTENT COUPLING
Order IDStatus
123 PLACED
456 SHIPPED
WarehouseOrder Processor
Information hiding bypassed
Unclear what can safely be
changed in the Order service
Aka Pathological Coupling
@samnewman
IN SUMMARY
Information hidingis super important
Some coupling is worse than others
Information hiding, low coupling, strong
cohesion = Independent Deployability