Wednesday, November 15, 2017

A Review of Clean Architecture

Robert C. Martin's ("Uncle Bob") Clean Code was a real eye opener for me when I read it a few years ago. I learned many things from Clean Code and it made me a better programmer.

Recently I've become increasingly interested in software architecture. So when I heard Clean Architecture was coming out, I ordered it immediately.

As I was pouring over the Table Of Contents in preparation of this review I caught myself thinking: "Did I read all that in just a few days"?! That really is a testament to Uncle Bob's ability to make such a book a breeze to read. It is very accessible, sprinkled with personal anecdotes and a bit of humor.

Due to the nature of the subject it is somewhat less readily applicable to my everyday work than Clean Code is. Still, it is a very practicable book, a few more theoretical chapters not withstanding. Certainly, next time when starting a new project I will apply a Clean Architecture.

The book starts out by defining what architecture is and isn't. Martin makes the point that a good architecture should make it easy to change the code when requirements change.

What follows is a nice overview of the history of software engineering and how programming evolved, including a summary of the three programming paradigms: functional, object oriented and structured programming.

When the book dives into the meat and potatoes of clean architecture it is really good. Uncle Bob covers several architectural principles, including the SOLID principles which are just as applicable to architecture as to code. Various chapters are devoted to how and where to draw boundary lines in the code, decoupling and keeping options open.

While reading I kept thinking "yes, yes, I agree!". The book validates many of the ideas I have about software architecture, like abstracting databases, frameworks and other third party components and relegating them to the fringes of your program, rather than putting them front and center. As Martin puts it: the database (or framework, or the web) is a detail.

A case study and an example of the architecture of a simple game show how to apply Clean Architecture in real life situations.

The final chapter, written by Simon Brown, deals with architecture in a bit more detail and presents some options on how to divide code across architectural layers.

An appendix allows Uncle Bob to tell some anecdotes from his early career (up until the early 1990s) and how certain successes and failures shaped his ideas about architecture. While sometimes going off on a tangent, I found it really interesting, and sometimes painfully recognizable, to read.

The cover promises an afterword by Jason Gorman, but I wasn't able to find it. Is it me, or is this an omission?


Conclusion

Don't expect a book that tells you which frameworks and database systems to use. Clean Architecture is not about details like how to use Azure Services or Entity Framework 6. On the contrary, this books focuses on timeless architecture that is resilient to change.

I enjoyed reading it and can recommend Clean Architecture to anyone with an interest in software architecture.