Saturday, October 22, 2005

Code Complete Review

I read Code Complete by Steve McConnell again this past week. This book is one of the few books I recommend for every programmer on my website. Anyone can read a book on how to code C++ in 21 days, but that doesn't make them a competent programer. After a few years of programing you will learn things from other programmers and from yourself. Not big things, but little things such as:

When working on a problem often times it helps to go to someone else and talk it out. You will probably find that all you need to do it talk out the problem, the other person doesn't even have to say anything.

or

Hard coding that 48 pixel size for every toolbar button isn't a good idea, using a global define is much better.

Your average computer book normally don't concentrate on these types of topics/tips, because they aren't important in teaching you PHP, C++ or how to design user interfaces. But they do make you more productive by making your code more easier to read, easier to maintain, and easier to debug. This book doesn't just teach you tips for writing code, but also dealing with schedules, managers, projects, and everything project related. I do not know of another book that contains the breadth of tips like Code Complete. Here are just a few of the types of tips that are contained in the book:
  • How to use parameters
  • How to name boolean variables
  • Different types of design
  • Enumerated Types, when to use them, and how
  • How to write defines (named constants) and why you should
  • Use variables as short of a time as possible and why
  • When to use a while loop over a for loop
  • When not to use break
  • Tips with boolean expressions
  • Benefits of structured programming
  • How to lay out and format your code (white space etc)
  • Keys to effective comments
  • Estimating schedules
  • Debugging, more then just printf()
  • Project integration strategies
  • Optimization strategies
Those who program in the open source world will find themselves exposed to many similar tips and tricks just by reading other peoples code. In fact this is one of my favorite parts about open source. As I read others code I often learn something new. Then when you submit patches they might be rejected not based upon correctness, but upon how the code is formatted, comments, or other bits that matter more in the long run.

I would recommend Code Complete to any programmer. Beginner programers will of course get more out of it and older programmers will find the book contains many good reminders and perhaps some tips they knew, but had never defined.

No comments:

Popular Posts