Code Complete 2!

schwern on 2004-07-07T21:29:01

The unfortunately grey cover of Code Complete 2 tells you there will be no Electric Buggaloo here.

The second edition of Code Complete is out and its as good as the first edition. If I had to hand someone just one book on software engineering this would be it. BUY BUY BUY BUY!

This book covers code construction issues. Even better it contains lots of code examples and statistics. None of this high level ideas, heuristics and hand waving. He gets down into the nitty gritty and takes on things like variable naming, proper use of conditionals and loops, how to draw your subroutine lines. Anything that involves writing code is fair game. Refactoring. Testing. Pair programming. Error handling. Debugging.

What's different from the first edition? The examples are primarily in C++ (with some Java and Visual BASIC thrown in for, ummm, variety?) but have no fear, they never get complicated and rarely language specific. Any decent Perl programmer will be able to read the examples and the advice is language agnostic for the most part. He's adapted the text a bit for the new more flexible methodologies that involve a lot of change and a lot less explicit design.

However, the author does have a bias towards C++ and this sometimes leads to tips and pointers that are useless for those of us who have high falutin' features like MEMORY PROTECTION. For example, in the chapter on Offensive Programming he talks about filling your objects with garbage before deleting them to find code trying to use the object after its been destroyed. ITS TWO THOUSAND FOUR! We might not have personal robots or flying cars but at least we should be able to rely on the computer to handle memory management! But such things are few and short.

Anyhow, great book. When I was learning how to program in '96 it was the pink camel and Code Complete. And look how I turned out.

And now in a petty aside. Please don't let it influence your opinion of the book.

Perl gets a pretty short shrift. Here's his description:

Perl is a string-handling language that is based on C and several UNIX utilities. Perl is often used for system administration tasks, such as building scripts, as well as for report generation and processing. It's also used to create Web applications such as Slashdot. The acronym "Perl" stands for Practical Extraction and Report Language.

At least he didn't call it PERL. Compare to Python.

Python is an interpreted, interactive, object-oriented language that runs in numerous environments. It is used most commonly for writing scripts and small Web applicccations and also contains some support for creating larger programs.

s/Python/Perl/ and it still fits. I want Guido's PR department. No, I want Microsoft's.

Visual Basic is a high-level, object oriented, visual programming version of Basic developed by Microsoft that was originally designed for creating Microsoft Windows applications. It has since been extended to support customization of desktop applications such as Microsoft Office, creation of Web programs and other applications. Experts report that by the early 2000s more professional developers were working in Visual Basic than in any other language.

To his credit he doesn't advocate any programming language.

Programmers are more productive using a familiar language than an unfamiliar one.

Programmers working with high-level languages achieve better productivity and quality than those working with lower-level languages.

And there's even a table of "Ratio of High-Level-Language Statements to Equivalent C Code" showing C++ and Java at 1:2.5 but Perl, Python and Smalltalk at 1:6! He even makes the link between natural language and computer language:

Some languages are better at expressing programming concepts than others. You can draw a parallel between natural languages such as English and programming languages...

uh uh, good good...

...such as Java and C++.

Ooop. There's that blind spot again. Desite his laying out an argument for using high level languages with natural language features, section 4.1 is the first and last time you'll hear about them in this book. Everything from here on out is C++, Java and Visual Basic with the occassional Fortran or C annecdote. With the possible exception of Visual Basic, that set of languages is possibly the *least* expressive and *lowest* level of the modern set. C++ only seems liberating to a C programmer. Java only looks like an improvement to a C++ programmer.

Anyhow, like I said, it doesn't detract from the usefulness of the book to Perl programmers.