Modular Monoliths
summary
Argues that you can get microservice-like modularity inside a single Java monolith by aligning architecture diagrams with code, using the C4/Structureizr approach and dogfooding it on Cloud Foundry + Spring. Demonstrates package by component with package-protected implementations, recommends enforcing boundaries via the compiler, Java 9 modules or multiple Maven modules, and automating checks with fitness functions and tools like JQAssistant and ArchUnit. Warns that microservices are often chosen for fashion, not need.
AI-written summary · about
chapters (33)
- 0:00Introduction
- 2:35A well structured codebase is easy to visualise
- 4:43the component exists conceptually
- 4:57Abstractions should reflect the code
- 7:17Our architecture diagrams don't match the code.
- 7:56The code structure should reflect the architectural intent
- 8:33Organise code based upon what the code does from a technical perspective
- 9:11Relaxed vs strict layering
- 11:53Changes to a layered architecture usually result in changes across all layers
- 12:42Organise code based upon what the code does from a functional perspective
- 12:56Package by feature is a "vertical" slicing
- 13:31Cited benefits include higher cohesion, lower coupling, and related code is easier to find
- 15:04The "inside" is technology agnostic, and is often described in terms of a ubiquitous language
- 20:09Architectural principles introduce consistency via constraints and guidelines
- 20:27web controllers should never access repositories directly
- 22:51Tooling? Static analysis tools, architecture violation checking, etc
- 23:18types in package **/web should not access types in **/data
- 23:55Using tools to assert good code structure seems like a hack
- 24:38But Java's access modifiers are flawed...
- 25:50Component? a grouping of related functionality behind a nice clean interface, which resides inside an execution environment like an application
- 27:08Package by component is about applying component-based or service-oriented design thinking to a monolithic codebase
- 27:28Modularity as a principle
- 27:54Separating interface from implementation
- 28:12Impermeable boundaries
- 29:21The devil is in the implementation details
- 30:15Organisation vs encapsulation
- 34:49Use encapsulation to minimise the number of potential dependencies
- 35:38If you're building a monolithic application with a single codebase, try to use the compiler to enforce boundaries
- 36:01Or other decoupling modes such as a module framework that differentiates public from published types
- 39:08Agility is a quality attribute
- 39:45A good architecture enables agility
- 45:58Whatever architectural approach you choose, don't forget about the implementation details
- 46:13Beware of the model-code gap
related talks
59mMajestic Modular Monoliths
01mModularization: Foundation of Microservices and Monoliths
43mMonolith? Microservices? Who cares?
51mModularization: Foundation of Microservices and Monoliths
52mMonoliths to Modular: Navigating the Transition
01h 01mBetter Monoliths — Modulithic Applications with Spring Boot
45mOnce Upon a Time... Modular Monolith: The Quest for the Perfect Architecture
01h 01mModular Monolith Instead of Microservices: How, When and Why
