Urgent.News

What's breaking now, across thousands of outlets.

Tech

Best Clean Code and Refactoring Books, and the Order to Read Them

Clean Code was the first text I handed to my students. Since then I have read the six other books fighting for the "clean code" shelf, and they do not all say the same thing. Sometimes they say the opposite. I wrote a reading note for each one. Here is the order I would follow if I were starting over, and what you can leave on the shelf. The craft before the rules The Pragmatic Programmer by…

Best Clean Code and Refactoring Books, and the Order to Read Them

Clean Code by Robert C. Martin, published in 2008, was the first book the author introduced to their students. However, later reading other books on clean code led the author to reconsider the order in which they recommend these titles. Here is the suggested reading order along with the author's assessment of each book's value.

The Pragmatic Programmer (2019 edition) by Andrew Hunt and David Thomas is the author's starting point. The book's tone is refreshing, with few commandments, many engaging stories, and a lack of condescension. The authors have even publicly corrected errors from the previous edition, which earns the book credibility. However, with 53 topics in 352 pages, the reader may find themselves skimming.

The tooling chapter is thin, and the code samples are presented in various languages with minimal focus on any one of them. The book is best read for its stories and mental models, rather than its code samples. Skipped samples and retained the rest.

Clean Code by Robert C. Martin follows the Pragmatic Programmer. This book teaches that code is read far more often than it is written. The chapters on naming, functions, and comments have stood the test of time. However, the rest of the book veers into verbose Java, and the final case-study chapters, totaling 90 pages, are largely redundant.

Despite the author's admission that the short-functions rule lacks research backing, his other principles have proven valuable. For a deeper understanding of software design, the author recommends John Ousterhout's A Philosophy of Software Design (2021), which has been hailed as one of the best software design books in the past two decades.

Ousterhout's deep module concept challenges the traditional line-by-line approach and emphasizes the trade-off between the learning cost of an interface and the benefits it provides. The modular approach is easier to grasp than to implement, especially when compared to the other two books in this list.

Steve McConnell's Code Complete (2004) is the next book on the list. The first hundred pages of this massive 960-page tome are the most valuable, offering insights on complexity, abstract data types, cohesive routines, and defensive programming that many developers learn through painful trial and error. While some aspects of the book have become outdated, including examples in C++, Visual Basic 6, and Pascal, the core concepts remain relevant.

The author's focus on humans, including the impact of code inspections, debugging psychology, and complexity as the universal enemy, is timeless. The author suggests focusing on Parts I, II, and VII, plus chapters 20 and 21, for a more manageable 250-page read, with the rest of the book serving as reference material.

Refactoring by Martin Fowler (2018) is the fourth book on the list and contains the author's most valuable code lesson. Chapter 1, which spans 70 pages, provides a rare, in-depth look at a developer at work, with every move meticulously explained and the code never breaking. Fowler's central argument, labeled as an unproven hypothesis, is essentially that the book's central thesis requires further research.

However, the book's honesty and focus on the refactoring process make it an essential read. The author admits that half the book is a dictionary of transformations that are rarely read in a single sitting, so the author recommends starting with chapters 1 to 4 and keeping the rest of the book on hand during code reviews. The Refactor menu in modern editors is a direct result of Fowler's work, and the book has significantly influenced code review practices.

Working Effectively with Legacy Code (2004) by Michael Feathers is the next book on the list. Feathers defines legacy code as code without tests, rather than old code. He introduces the concept of tests as snapshots of current behavior, which helps determine how to approach testing when the definition of correctness is unclear. The seam model, which identifies places where behavior can change without editing the code, helps readers read code by looking for joints.

Feathers also accepts that his techniques often result in temporarily uglier code, but emphasizes that the resulting scar is temporary. This candid approach makes the book a reliable resource. However, the book is dated, with only Java, C++, and C examples throughout. Part II, a 20-chapter FAQ format, often repeats the same four moves under different class names, so the author recommends opening the book at the chapter matching your specific problem and using it as needed.

Test-Driven Development: By Example (2002) by Kent Beck rounds out the author's book list. Unlike other books on this list, Beck does not sell a predefined recipe, but rather demonstrates a state of mind: calmness in the face of uncertainty, knowing that the code still functions. The author's TDD approach emphasizes moving forward without fear, rather than aiming for coverage.

Beck's micro-steps, including the TODO list and "fake it" strategies, have become essential for developers seeking to work with greater confidence. While the book's example code is outdated (2002 Java and Python 2), the core mindset and micro-steps are still relevant. The book is best read for the mindset it imparts, with the specific micro-steps adapted to the reader's own pace.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Ai2's Olmo-core 3 Keeps Every Expert on the GPU and Throughput Nearly Flat

TL;DR Olmo-core 3 is the open training framework the Allen Institute for AI builds its Olmo language models with, released as source code under the Apache 2.0 licence with a technical report beside…

  • Olmo-core 3 replaces fully sharded data parallelism with distributed data parallelism.
  • Throughput increases by roughly 2.7 times with Olmo-core 3 compared to previous implementation.

How to Investigate an Unknown Device on Your Home Network

An unfamiliar entry in your router’s device list is worth checking. On its own, though, it doesn't mean somebody has gained access to the network.

  • Examine router records for device details like date, time, IP address, and hardware address.
  • Check your owned devices (phones, tablets, smart home devices) for matching connection details.

More from Wednesday 14 October →