Get Your Hands Dirty on Clean Architecture: A hands-on guide to creating clean web applications with code examples in Java

by Tom Hombergs

What is hexagonal architecture? What are its advantages? And how do you implement a hexagonal application in Java? Tom Hombergs answers these questions in "Get Your Hands Dirty on Clean Architecture".

The author first describes the problems of the classic layered architecture and explains how the "Clean Architecture" described by Robert C. Martin and the "Hexagonal Architecture" introduced by Alistair Cockburn (which is comparable in principle) can better meet the requirements of a modern application (maintainability, adaptability, extensibility) – namely by placing the business domain (and not technical details) at the center of the architecture.

After a short theory follows the practice: Step by step, the author develops an exemplary Java application with entities, use cases, ports, and adapters. He presents different mapping strategies for the adapters and discusses their advantages and disadvantages.

He details how to cut and test components and proposes a package structure that makes the architectural style visible.

After all application components are finished, the author shows how they can be assembled – firstly with pure Java and secondly using the Spring Framework. Thus, he impressively demonstrates that even the implementation of dependency injection can be merely an interchangeable detail of the software.

After that, the author shows how the application can be modularized using separate build artifacts, e.g., Maven modules, so the architectural style cannot be easily bypassed. Unfortunately, the author does not address how the Java module system could also perform this task.

Finally, he discusses what shortcuts we can take when mapping between layers and what technical debt we need to be aware of.

The book is excellently structured and written understandably and concisely throughout. The author has managed to fit into just 138 pages what takes up more than four times the space in "Designing Hexagonal Architecture with Java" (a book I do not recommend and therefore do not list here). An outstanding achievement!

🎧 Suitable as an audiobook? No, due to numerous diagrams and code examples.

By the way, you can find a tutorial series on hexagonal architecture in the software craftsmanship section of this website.

Other Recommendations From This Books’s Genres

* Disclosure: We love sharing our favorite books with you! As an Amazon Associate, we earn a small commission from purchases you make through our links, which helps us continue creating content you enjoy.