Book Review: Code Complete 2

      2 Comments on Book Review: Code Complete 2

I’ve read a great book a couple of months back. And I just have to share it with you. The book is Code Complete 2 by Steve McConnell.

To put it simply, if you’re a developer you should have this book on your bookshelf. The author went over hundreds of books, articles, research papers… and compiled all of them into a book. So you’ll be gaining experience from a lot of sources. It’s kinda of a meta-book on software development.

This is a pretty long book, it’s over 800 pages long, so I can’t really go into too much detail about it, I’ll just cover some sections that I liked the most.

In part one of the book, the author is talking about laying the foundation to your projects. You should gather all the requirements before you actually start coding, establish code conventions, decide on the best architecture… If your project is properly defined before you start coding, then coding simply becomes a formality, there shouldn’t be any surprises. But if your requirements or the architecture you selected is wrong, it will be expensive to fix it later in the project. The later the error is noticed, the more expensive it is to fix, if an error is noticed when the project is finished/released it might cost you up to a 1000 times more to fix it then if the error was noticed during the initial stages of the project.

In part two you can read about creating high-quality code. These few chapters are loaded with great advice. Software design is about managing complexity, and everything we do should be as simple as possible. I believe Knuth said that early optimisation is the root of all evil, and I agree. You might spend days trying to optimise one class/method and at the end, it will be used by only 1% of the users who won’t even notice the performance gains. The author also talks about iterative design, this is an interesting concept. You evolve your design with your project, and the more possibilities you try, the better the final design will be. This kinda fits with the agile methodology of software development. In chapter 6 you can learn how to create a good class. It’s tempting to just subclass a class, and keep the shared code in the super class, but this will eventually complicate your class hierarchy. They say that a human mind can, on average, hold 7 individual pieces of information, so it’s good if you follow the single responsibility principle, and if you favour composition over inheritance.

There’s a whole part of the book dedicated to variables, from naming them to using them properly. We all know that one of the hardest things in software development is naming variables 🙂 So naming conventions are a good thing to have. We read a lot more code than we write, so having good variable names is very important. This is definitely worth reading.

Avoiding massively nested if-else conditionals and making loops simple and manageable is the main topic of part four. You can find loads of useful advice in this part.

One of my favourite parts is part five. It talks about code improvements. It has loads of info on how to improve the code quality, from code reviews and testing plans to following common guidelines. It might be a bit slower to develop software with all these mechanisms in place, but fixing some nasty bugs later in the production would definitely be more expensive. One of the ways of improving quality is collaborative construction (code reviews, pair programming, walkthroughs…) You choose what works best for your project, maybe even choose multiple things. And, of course, testing is a way to improve the quality of your code. If you realise you made a mistake designing a class you can always refactor it, you can find some specific useful advice on ways to refactor your code.

Conclusion

I honestly believe that every developer should read this book, and keep it on hers/his desk. You will benefit from vast experience and knowledge gathered from hundreds of books/articles. And at the end, it will make you a better developer. This has been a lengthy review, I hope I didn’t bore you to death, I hope I helped you with your reading choices for the next month 🙂

Have a nice day 🙂

Dejan.

More resources

2 thoughts on “Book Review: Code Complete 2

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.