Part 04
Software Design and Application Architecture
Structure an application into clear modules and record design decisions.
4.1 Object-Oriented Design and SOLID
Chapter outcomes and context
Topics covered: 43 Object-oriented design (Core) · 44 SOLID principles (Core)
Learning outcomes
- Apply encapsulation, composition, polymorphism, and interfaces to model a domain; prefer composition over inheritance.
- Apply SOLID as design pressure, not dogma: Single Responsibility (one reason to change), Open/Closed (extend without modifying stable code), Liskov Substitution (subtypes honor the base contract), Interface Segregation (small, client-specific interfaces), Dependency Inversion (high-level policy does not import low-level detail).
When not to apply: over-abstraction. An interface with one implementation and no test seam is noise; a concrete class is the simpler alternative until a second implementation exists.
4.2 Modeling and Communicating Design
Chapter outcomes and context
Topics covered: 45 UML and architecture modeling, including the C4 model (Core) · 46 Sequence and state diagrams, state machines (Core)
Learning outcomes
- Use the C4 model levels — context, container, component, code — to pick the right zoom level for an audience.
- Draw class diagrams for structure and sequence diagrams for interactions over time (the workhorse of LLD).
- Model lifecycle-bearing entities as state machines: states, legal transitions, transition guards — and enforce them in code, not in comments. Order status and payment status are state machines (Project 6 depends on this).
- Treat each diagram as the answer to exactly one question.
4.3 Design Patterns and Data Access
Chapter outcomes and context
Topics covered: 47 Creational, structural and behavioral design patterns (Core) · 48 Data access patterns: repository and unit of work (Core)
Learning outcomes
- Know the patterns that recur in backend code, each with its when-not-to-use:
- Creational: Factory Method, Builder, Singleton (usually a disguised global — prefer dependency injection).
- Structural: Adapter, Facade, Decorator, Proxy.
- Behavioral: Strategy, Observer, Template Method, Command, State.
- Apply the data access patterns (primary home):
- Repository — a collection-like interface over persistence, isolating the domain from the database and providing a test seam. When not to use: the ORM already is an adequate boundary.
- Unit of Work — tracks changes within one business operation and commits them atomically. Simpler alternative: a single transaction scope for single-aggregate writes.
- Treat patterns as vocabulary for recurring solutions, never as targets to hit.
4.4 Dependencies and Application Structure
Chapter outcomes and context
Topics covered: 49 Separation of concerns and dependency management (Core) · 50 Layered architecture (Core) · 51 Clean architecture (Advanced) · 52 Hexagonal architecture (Advanced) · 53 Modular monolith architecture (Core)
Learning outcomes
- Keep modules cohesive and loosely coupled; make dependencies explicit via injection; detect and break dependency cycles.
- Layered architecture — presentation / application / domain / infrastructure, with dependencies pointing downward: the sensible default for most applications.
- (Advanced) Hexagonal (ports and adapters) and Clean architecture — the domain core defines interfaces; adapters (HTTP, database, queue) plug in at the edges; dependencies point inward. Choose when the domain is rich and long-lived. When not to use: five layers of interfaces around a CRUD application is ceremony.
- Modular monolith (primary home) — one deployable, strictly separated modules with explicit interfaces and no shared tables between modules. The honest alternative to premature microservices (→ 143), and the deliberate shape of Projects 1, 2, 3, 5 and 6.
Decision rule: layered for straightforward applications; hexagonal/clean when domain complexity earns it; modular monolith when you want service boundaries without distribution costs.
4.5 Domain-Driven Design
Chapter outcomes and context
Topics covered: 54 Domain-driven design (Advanced) · 55 Entities, value objects and aggregates (Advanced) · 56 Bounded contexts and domain boundaries (Advanced)
Learning outcomes
- Build a ubiquitous language with domain experts and make the code speak it.
- Model with the tactical tools:
- Entity — identity that persists through change (Order #123).
- Value object — defined by its attributes, immutable (Money, Address).
- Aggregate — a consistency boundary with one root; transactions do not span aggregates.
- Draw bounded contexts — explicit boundaries inside which a model is consistent — and map the relationships between them. Bounded contexts are the primary input to service boundaries (→ 145); errors there begin here.
When not to use: full DDD on a simple CRUD domain. The simpler alternative — a clear relational model and a service layer — serves most applications.
4.6 Architecture Decision Records
Chapter outcomes and context
Topics covered: 57 Architecture documentation and decision records (Core)
Learning outcomes
- Write ADRs: context, options, decision, consequences — one page, immutable once accepted, superseded rather than edited.
- Keep architecture documentation minimal and current: C4 diagrams (→ 45) plus ADRs beat a stale hundred-page document.
Done when you can
- Structure a non-trivial application so the domain logic has no framework imports.
- Model a lifecycle as an enforced state machine.
- Model a business domain as aggregates and bounded contexts.
- Record and defend architectural decisions in ADR form.