Several years ago, when I was just getting started as a software developer, I read Steve McConnell's Code Complete all the way through, cover to cover. Then I went back and read several sections again. There is no question in my mind that as a result I immediately became a far better developer than I was at that time-not only that, my entire mindset was changed. Since then, I've returned to the book countless times, reading many parts of it again and again. I've recommended it to all the aspiring or less experienced developers with whom I've had the pleasure to work. Every time I interview a candidate for hire, I want to know whether he or she has read this book.
Why do I consider this such an important book for developers? Here are a few reasons:
1) Code Complete focuses on the absolute fundamentals of programming-in other words, the little details. By this I don't mean that the book is a programming instruction manual. It does assume that you know the absolute basics of variables, data types, branching, looping, etc. Beyond that basic assumption, though, McConnell dives into the how and why of fundamental concepts such as data and routine naming, when and how to decide to break code into routines and modules, indenting, declaring variables, appropriate and tactical use of data types, properly writing If statements and loops, named constants, commenting, layout and style, etc, etc. The book also goes into detail on higher level, yet still fundamental, topics such as unit testing, debugging, tuning, and delivery. Sadly, these are fundamental topics in which too many developers never get any real guidance or instruction.
2) Almost as important as this instruction in the critical techniques and best practices of writing code is the message that McConnell weaves throughout the book: quality matters, and as the person writing the code, you have a personal responsibility to everyone affected by your code to do good, high quality work. This is the single most important characteristic I look for when hiring developers: I want to know if a developer cares about quality, about doing things "the right way." The message of quality goes hand-in-hand with McConnell's focus on "the little things." My only complaint in this area: Chapter 31, titled "Personal Character," should have been Chapter 1. (Then again, maybe McConnell knew what he was doing by not hitting people over the head with that one right away.)
3) Many developers, when they are first starting out, work by themselves. If the only audience for your code is yourself, then it might not occur to you to be concerned with exactly how to indent a nested loop or how to write good comments. McConnell does a great service for developers in this situation by shining a light on what it is like to work with a team of programmers who share code and responsibilities such as testing and documentation.
4) Looking back, one of the most important benefits that I received from Code Complete is a glimpse into the history of software development, which inspired me to read further and become a student of the discipline and craft of building software. McConnell does not simply dispense with a lot of advice and expect you to take his word for it. Code Complete is a distillation of thousands of pages of books, academic papers, and studies, a fact which McConnell makes quite explicit. He repeatedly refers directly to these primary sources. This not only reinforces his points, but also introduces the reader into a wider world. The book's last chapter, called "Where to Go for More Information" is full of great ideas for further reading.
It's interesting to go to Amazon.com and read the 100+ reviews of this book. The vast majority of them are glowing five star reviews. Many of the less favorable reviews criticize the fact that, since Code Complete was published in 1993, it does not discuss the issues of software construction in terms of the object oriented languages and n-tier architectures that are popular today. If one wanted to look for them, it would be easy to find ideas and conclusions in the book that seem dated. It would be easy to get hung up on the fact that many of the examples are written in languages like Pascal, C, C++, Ada, Modula-2, Fortran, and Basic.
As you might guess, I don't buy the argument that Code Complete is any more than a little out of date. While I agree that it would be nice if McConnell would write an updated version of the book, my guess is that the reason he has not done so is that it would take hours of work, and probably only increase the value of the book by 5% or so. Yeah, it would be cool if the examples were in Java, C#, or Ruby, but the languages are totally beside the point. And yes, the book would be improved if the discussions of modules and routines also discussed objects and methods, but the exact language-specific implementation details of the principles of modularization are also beside the point.
Let's look at my argument in a different way. I see three audiences for Code Complete:
- People who have written some programs but who are really just hacking at it, with no sense of stylistic purpose or conscious technique
- Seasoned programmers who like to sharpen their skills and refine their style, or who are looking for a book to recommend to those in the first two audiences
The first two groups are the primary audience of Code Complete, and a book aimed at these two groups would totally fail if it turned on the fire hose and said to the reader, "Open wide!" The people in these groups are primarily building their first ASP web sites, simple desktop utilities, scripts, and basic database applications. With a firm grounding in the fundamentals, and with more experience and learning behind them, newer developers can eventually get to the point where they are ready to balance cohesion, coupling, protected variations, separation of concerns, performance, public vs. private interfaces, exception handling, transactions, workflow, persistence, object/relational mapping, and security, not to mention domain-specific concerns like cross-process marshalling, threads, memory management, etc. McConnell does the right thing by keeping the focus of Code Complete on the basic building blocks.
If you are a person in those first two groups, you need to buy a copy of this book right now. That's a strong statement, but I stand by it. If you are in that third group, and have not yet read this great book, I recommend it to you for the sheer pleasure it will bring.