Overview
Syllabus
Introduction
A well structured codebase is easy to visualise
the component exists conceptually
Abstractions should reflect the code
Our architecture diagrams don't match the code.
The code structure should reflect the architectural intent
Organise code based upon what the code does from a technical perspective
Package by layer is a "horizontal" slicing
Relaxed vs strict layering
Changes to a layered architecture usually result in changes across all layers
Organise code based upon what the code does from a functional perspective
Package by feature is a "vertical" slicing
Cited benefits include higher cohesion, lower coupling, and related code is easier to find
The "inside" is technology agnostic, and is often described in terms of a ubiquitous language
Architectural principles introduce consistency via constraints and guidelines
web controllers should never access repositories directly
Tooling? Static analysis tools, architecture violation checking, etc
types in package **/web should not access types in **/data
Using tools to assert good code structure seems like a hack
But Java's access modifiers are flawed...
Component? a grouping of related functionality behind a nice clean interface, which resides inside an execution environment like an application
Package by component is about applying component-based or service-oriented design thinking to a monolithic codebase
Modularity as a principle
Separating interface from implementation
Impermeable boundaries
The devil is in the implementation details
Organisation vs encapsulation
Use encapsulation to minimise the number of potential dependencies
If you're building a monolithic application with a single codebase, try to use the compiler to enforce boundaries
Or other decoupling modes such as a module framework that differentiates public from published types
Agility is a quality attribute
A good architecture enables agility
Whatever architectural approach you choose, don't forget about the implementation details
Beware of the model-code gap
Taught by
GOTO Conferences