1 / 11
A practical guide to code that stays easy to change: SOLID, the classic design patterns, Clean/Hexagonal/Onion Architecture, Domain-Driven Design, and safe refactoring, applied to one real codebase. 28 chapters, 4 appendices, 493 pages (PDF).
Writing Maintainable Code
Read before you buy: the PDF here is a free sample — the first 20 pages of the 493-page book (payments, sales and reviews on this demo site are sample data). Get the full e-book at thenexbooks on Gumroad.
Stop fighting your own codebase. Learn to design software that stays easy to change.
Almost every codebase starts clean. Then the product succeeds, features pile up, and one day a change that should take an afternoon takes two weeks and breaks something unrelated. The ideas that prevent this — SOLID, design patterns, Clean Architecture, Domain-Driven Design, refactoring — are well known, but usually taught in isolation, with toy examples, or as rules to obey.
This book takes a practical path: one realistic system that grew into a tangled monolith, improved step by step. Every principle and pattern appears where it solves a real problem, with before-and-after code, the costs it adds, and when you should not use it at all.
What's inside
- Coupling, cohesion, and the cost of change — the forces behind every design decision
- Clean code habits, the SOLID principles, composition, and dependency injection without dogma
- Refactoring safely with code smells, characterization tests, and small steps
- Creational patterns: Factory Method, Abstract Factory, Builder, Singleton
- Structural patterns: Adapter, Facade, Decorator, Composite, Proxy, Bridge, plus value objects and Null Object
- Behavioral patterns: Strategy, Template Method, Observer and domain events, Command, Chain of Responsibility, State, Specification, Visitor, Iterator
- Clean, Hexagonal, and Onion Architecture compared; the dependency rule; use cases; ports and adapters; enforcing module boundaries
- Domain-Driven Design: ubiquitous language, bounded contexts, aggregates, repositories, Unit of Work, CQRS, and the outbox pattern
- Testing an architecture, including architecture tests that fail the build when layers are violated
- Migrating legacy code with seams and the Strangler Fig; handling errors, validation, logging, and observability cleanly
One running example, start to finish. You untangle Brewline, a fictional coffee roastery's online platform: pricing rules, subscriptions, shipping carriers, a payment provider, and a legacy ERP.
Language-neutral ideas, readable code. Examples are in TypeScript, which reads naturally for Java, C#, Kotlin, Go, and JavaScript developers. Every chapter includes Tips, Notes, and Warnings, and ends with Key Takeaways.
Format: PDF, 493 pages (A4), linked table of contents and bookmarks. English. First Edition, 2026. Published by thenexbooks.
Table of Contents
Part I — Foundations of Maintainable Code
- Ch 1 · Why Maintainability Matters: Cost of Change, Coupling, and Cohesion
- Ch 2 · Clean Code Essentials: Naming, Functions, and Readable Structure
- Ch 3 · SOLID Principles in Practice
- Ch 4 · Composition, Interfaces, and Dependency Injection
- Ch 5 · Refactoring Safely: Code Smells, Tests as a Safety Net, and Small Steps
Part II — Creational and Structural Patterns
- Ch 6 · Thinking in Patterns: When Patterns Help and When They Hurt
- Ch 7 · Creational Patterns: Factory Method, Abstract Factory, Builder, and Singleton
- Ch 8 · Structural Patterns I: Adapter, Facade, and Decorator
- Ch 9 · Structural Patterns II: Composite, Proxy, and Bridge
- Ch 10 · Value Objects, Immutability, and the Null Object Pattern
Part III — Behavioral Patterns
- Ch 11 · Strategy, Template Method, and Policy Objects
- Ch 12 · Observer, Domain Events, and Publish-Subscribe
- Ch 13 · Command, Chain of Responsibility, and Middleware Pipelines
- Ch 14 · The State Pattern and Explicit State Machines
- Ch 15 · Specification, Visitor, and Iterator
Part IV — Clean Architecture
- Ch 16 · Architecture Fundamentals: Layers, Boundaries, and the Dependency Rule
- Ch 17 · Clean, Hexagonal, and Onion Architecture Compared
- Ch 18 · Entities and Use Cases: Modeling the Core of the Application
- Ch 19 · Ports and Adapters: Controllers, Presenters, Gateways, and Repositories
- Ch 20 · Organizing Code: Package by Feature, Modules, and Enforcing Boundaries
Part V — Domain-Driven Design and Data
- Ch 21 · Domain-Driven Design Essentials: Ubiquitous Language and Bounded Contexts
- Ch 22 · Aggregates, Invariants, and Domain Events
- Ch 23 · Persistence Without Pollution: Repositories, Unit of Work, and Mapping
- Ch 24 · CQRS, Event-Driven Integration, and the Outbox Pattern
Part VI — Sustaining Maintainability
- Ch 25 · Testing an Architecture: Unit, Integration, Contract, and Architecture Tests
- Ch 26 · Refactoring Legacy Code Toward Clean Architecture: Seams and the Strangler Fig
- Ch 27 · Cross-Cutting Concerns: Errors, Validation, Logging, and Observability in a Clean Design
- Ch 28 · Case Study: Evolving Brewline from a Big Ball of Mud to a Clean Architecture
Appendices
A · Patterns and Principles Cheat Sheet
B · Templates and Reference
C · Maintainability Review Checklist
D · Glossary
Book details
| Detail | |
|---|---|
| Pages | 493 |
| Format | PDF (A4) |
| Language | English |
| Level | Intermediate to Advanced |
| Edition | 1st Edition (2026) |
| Download on this site | Free sample, first 20 pages (PDF) |
| Publisher | thenexbooks |
Files you get
No reviews yet. Only buyers can review.
More from thenexbooks