Code Complete Book Review (7 of 7)

This is the final piece of my review of Code Complete by Steve McConnell. This final section is about craftsmanship, and how we can approach construction as a craft. There are companies and groups dedicated to this pursuit. As we progress in our professional development it seems natural that we adopt these practices as well. Many of the readers of these posts are finding them via specific search queries, so I know people are thinking about this and looking to adopt these ideas.

  • Software Craftsmanship
    • Layout and Style
      • The most important part of code layout is making it easy to read for the next programmer. Use of whitespace, grouping and indentation make it easier for programmers to understand your program control flow.
      • When it comes to laying out comments, I'm a proponent of only commenting routine definitions. If you need to comment some tricky code, then that code needs to have it's own routine. In modern IDE's, this documentation will be available to future programmers via the class browser.
      • Layout Checklist
    • Self-Documenting Code
      • All development will require some external documentation in the form of design documents, test plans and more. As our tools permit, more of these documents are becoming executable, which allows for quicker round-trips between requirements, design, development, testing, and defect tracking.
      • Rather than documenting your code, we should strive to choose good routine and variable names, so people who read the code can understand what is going on without referring to documentation.
      • Self-Documenting Code Checklist
      • Use the Pseudocode Programming Process to document your code. This has the benefit of forcing you to think through your program flow before you start coding.
    • Personal Character
      • Since the main productive asset in development is people, we are required to develop certain personal characteristics to perform our jobs. These include:
        • honesty
        • humility
        • curiosity
        • creativity
        • discipline
    • Themes in Software Craftsmanship
      • Conquer Complexity: The best way to make system more modular is to break complex sections into easier sub-components. Every time you run into a difficult problem, start decomposing the problem until you have a list of simple problems.
      • Write Programs for People First, Computers Second: Every year hardware gets faster and cheaper. However, programmer time gets more expensive. Focus your development on making things easy to understand for the next developer and don't worry about squeezing every last bit of performance out of the current system.
      • Focus Your Attention with the Help of Conventions: Standardizing on variable names, indentation, and other conventions allows your brain to build muscle memory to make certain checks automatic. Sports have conventions (how to hold a baseball bat, a three-point stance in football) to train our body how to setup. The real thinking starts after these standards.
      • Program in Terms of the Problem Domain: Take advantage of OOP and layer your program so systems components talk to system components, and business logic talks to business logic. This composition is easier to read, easier to maintain, and easy to explain.

    This material is copied and/or adapted from the Code Complete 2 Website at cc2e.com. This material is Copyright © 1993-2007 Steven C. McConnell. Permission is hereby given to copy, adapt, and distribute this material as long as this notice is included on all such materials and the materials are not sold, licensed, or otherwise distributed for commercial gain.

  • Comments are closed