Clean Code and Architecture
This article corresponds with the launch of my GitHub repo, clean-code, which is meant to serve as a reference for myself and others on the topic of clean code and architecture. It is based on my experience studying these principles and includes code examples, analogies, and other observations. The two books I mention below are Effective Java and Design Patterns.
Clean, maintainable code is very often undervalued and underappreciated by product managers and engineering managers who are more focused on short-term deliverables than maintainability over the long-term. Sort of like investors who can’t see beyond short-term profitability and returns. There’s no patience for long-term strategies, and this often leads to perverse behavior. But neglecting the maintainability of a codebase is a costly mistake. We all know the cliche: a change that should have taken five minutes took hours or even days. So why not take that cliche to heart and do something about it?
I can honestly say that studying clean code and architecture has allowed me to take my career to the next level and given me confidence when writing code, discussing design decisions, and beyond. I only wish I had spent more time studying these topics earlier in my career. Their importance cannot be understated. In fact, they are an indispensable part of becoming a successful engineer at the highest levels of the profession.
Someone once gave me the advice to study Effective Java before the Gang of Four Design Patterns. I had actually just purchased Design Patterns, so I figured it was too late to turn back. I ended up wasting a lot of time reading this book, and over time it became very clear that it gave me a very low return on investment. I’m sure it was groundbreaking work when it was published, but I do not recommend anyone attempt to read it. To be clear, it is still perfectly useful as a reference and is frequently cited in other works. A perfect example — Effective Java has references to Design Patterns, so if you really want to go deep into one of the patterns, you can still do that.
One more reason why studying clean code an architecture is worth your time: I have been asked questions in interviews which I later realized were straight out of this field. For example, in an interview I was asked to create an immutable value class in Java. It turned out this is neatly explained in seven pages of Effective Java (Item 17: Minimize mutability). So keep in mind that this is in no way theoretical. It is very practical knowledge.