Why Every Computer Science Student Should Read “Clean Code”

RMAG news

When I interned as a software engineer at Amazon, our team collectively read Clean Code: A Handbook of Agile Software Craftsmanship. This book is considered a staple of agile software development, offering a thorough guide to writing high-quality, maintainable code. Its author, Robert C. Martin, is renowned for his contributions to the original Agile Manifesto and for establishing the SOLID principles of object-oriented design.

The insights from this book helped dictate the design decisions and team-wide rules I implemented as a technical lead for various non-profits, and in the code I developed during multiple software internships. Furthermore, after participating in over 50 rounds of algorithm interviews, I observed how frequently the book’s principles could be immediately applied to enhance code quality in these interviews. In other words, Clean Code is filled with straightforward design principles that, once understood, can be utilized in all aspects of your software development career.

In this article, I’ll talk about why every student aspiring to be a software engineer should read Clean Code, and how to approach its content effectively.

Why Read Clean Code?

Critical, But Not Taught In School

As a student, you often work on coding assignments as an individual or in a team, write out some poorly-named unit tests, submit your work 2 minutes before the deadline, and then pat yourself on the back. You rest easy knowing that you’ll never have to think about altering or extending that code again.

The habits we build when learning to write code in school are completely misaligned with the demands of the real world. Dominant in the software industry is the concept of continuous delivery — starting with a functional product and iterating on it over time. Thus, the coding style decisions you make when laying the groundwork of a codebase are of paramount importance. They can either enhance engineering efficiency exponentially, or make a codebase so convoluted that a major refactor is required later down the road.

The ability to write clean and effective code is a highly sought-after skill. By mastering its principles early, you can easily distinguish yourself among the ever-growing sea of students and entry-level developers.

Foundation of Best Practices

Without an understanding of industry standards and practices, many coding decisions made by students are based on their own intuition. Sure, that means that you can come up a with good, even creative solutions, but these will almost always fall short of the established best practices.

Reading a book like Clean Code and consistently practicing its teachings is the best way to learn industry standards without actually spending time in the industry. It is effectively “gaining experience without having experience.”

How To Read Clean Code

Get It For Free

The awesome part of being a college student is that your library will give you access to a massive pool of resources for free (minus crippling student debt). Most college libraries offer access to O’Reilly’s online library at www.oreilly.com using your university email address. O’Reilly Media publishes many major books related to IT, software engineering, and tech. Their catalog includes thousands of titles, including C++ Primer, The Pragmatic Programmer, Inspired, and Designing Data-Intensive Applications.
If you’re unable to log in to O’Reilly with your university email address, check whether the book is available through your school’s library catalog website. If not, you can often request materials through your library. Simply search for “request materials [university name]” on Google, and fill out a request form for access to O’Reilly or Clean Code.

Skim The Boring Stuff, Read What Matters To You

Not everything you read in Clean Code will make sense or be relevant to you. Perusing the table of contents, it’s easy to be overwhelmed by the myriad of different topics this book covers, and that’s perfectly fine. Clean Code is intended as a handbook — a resource to consult when facing a problem and seeking guidance toward a solution. Focus on understanding the thought processes behind the topics you frequently encounter (e.g., Chapters 1–7, 9, 10, 17), and only briefly skim the introductions of concepts you rarely deal with (e.g., Chapters 11–16).

Know that writing clean code requires constant practice, and it’s easy to forget the principles you read about without applying them. So, a mere glance through sections that don’t seem immediately relevant is more than sufficient. That way, you’ll know where to find guidance for certain topics if they become pertinent in the future.

Criticism of Clean Code

Any discussion of the book Clean Code is not without some contention. Central to arguments against the book is the 2020 article “It’s probably time to stop recommending Clean Code” by qntm (Sam Hughes). Here, qntm dissects several code examples from Clean Code, highlighting flaws and outdated practices. Qntm argues that some of Martin’s advice, while well-intentioned, is either overly simplistic or no longer relevant given advancements in software development since the book’s publication in 2009.

Rigid Rules

Critics of Clean Code often highlight that the book’s rigid rules can lead to code that is exceedingly verbose or complicated. Martin adopts a tone of absoluteness to really drive home the points that he’s making, and critics argue that following his principles to a tee can sometimes hinder rather than help, especially in real-world projects where flexibility and pragmatism are crucial.

For example, Martin’s stance on comments — “The proper use of comments is to compensate for our failure to express ourselves in code…Comments are always failures” — is seen by some as too extreme. Critics argue that comments are situationally necessary and that approaching them with such dogmatism can be counterproductive.

Similarly, Martin’s suggestion that “functions should be very small,” ideally “two, or three, or four lines long,” can result in fragmented, overly complex code filled with indirection if followed too strictly.

Steer — Never Dictate — Your Judgement

In the conclusion of Chapter 1, Martin states:

Books on art don’t promise to make you an artist. All they can do is give you some of the tools, techniques, and thought processes that other artists have used. So too this book cannot promise to make you a good programmer. It cannot promise to give you “code-sense.” All it can do is show that the thought processes of good programmers and the tricks, techniques, and tools they use.

Some software teams see Clean Code as an opportunity for cohesion and unity within a codebase. They treat it as a rule book that — if rigidly followed — will yield immediate benefits across the team. However, the reality (and beauty) of code design is how much of it is open to interpretation, and it’s impossible for one book and its set of “rules” to be the best approach for every situation in the rapidly evolving field of software engineering.

When reading this book, be excited by the opportunity to expose yourself to a whole myriad of ways to write clean, maintainable code. There will be points that you’ll agree resoundingly with, or revelations you’ll have about code cleanliness that you’ve never thought of before. Conversely, there will be times where you won’t agree with something that Martin has to say. This is not only expected but encouraged.

The essence of becoming a skilled programmer lies in developing your own judgment. Clean Code provides a framework, but it’s your responsibility to adapt and evolve it to fit the unique needs of your projects and teams. Embrace the principles that resonate with you and critically assess those that don’t, understanding that flexibility and discernment are key components of excellence in software development. Remember that the goal is not to follow a set of rules blindly, but to cultivate a mindset of continuous improvement and thoughtful consideration in your coding practices.

Happy Reading!

If you found this article helpful, you’re welcome to subscribe to my Medium as I aim to continue to share learnings from landing Intern/Graduate Software Engineer roles.

Cover Image by carolyn christine on Unsplash