Code Complete, 2nd Edition

Book description

Widely considered one of the best practical guides to programming, Steve McConnell’s original CODE COMPLETE has been helping developers write better software for more than a decade. Now this classic book has been fully updated and revised with leading-edge practices—and hundreds of new code samples—illustrating the art and science of software construction. Capturing the body of knowledge available from research, academia, and everyday commercial practice, McConnell synthesizes the most effective techniques and must-know principles into clear, pragmatic guidance. No matter what your experience level, development environment, or project size, this book will inform and stimulate your thinking—and help you build the highest quality code.

Discover the timeless techniques and strategies that help you:

  • Design for minimum complexity and maximum creativity

  • Reap the benefits of collaborative development

  • Apply defensive programming techniques to reduce and flush out errors

  • Exploit opportunities to refactor—or evolve—code, and do it safely

  • Use construction practices that are right-weight for your project

  • Debug problems quickly and effectively

  • Resolve critical construction issues early and correctly

  • Build quality into the beginning, middle, and end of your project

Table of contents

  1. Code Complete, Second Edition
    1. Contents at a Glance
    2. Table of Contents
    3. Preface
      1. Who Should Read This Book?
        1. Experienced Programmers
        2. Technical Leads
        3. Self-Taught Programmers
        4. Students
      2. Where Else Can You Find This Information?
      3. Key Benefits of This Handbook
      4. Why This Handbook Was Written
        1. The Topic of Construction Has Been Neglected
        2. Construction Is Important
        3. No Comparable Book Is Available
      5. Author Note
    4. Acknowledgments
    5. About the Author
      1. Steve McConnell
    6. I. Laying the Foundation
      1. 1. Welcome to Software Construction
        1. 1.1. What Is Software Construction?
        2. 1.2. Why Is Software Construction Important?
        3. 1.3. How to Read This Book
        4. Key Points
      2. 2. Metaphors for a Richer Understanding of Software Development
        1. 2.1. The Importance of Metaphors
        2. 2.2. How to Use Software Metaphors
        3. 2.3. Common Software Metaphors
          1. Software Penmanship: Writing Code
          2. Software Farming: Growing a System
          3. Software Oyster Farming: System Accretion
          4. Software Construction: Building Software
          5. Applying Software Techniques: The Intellectual Toolbox
          6. Combining Metaphors
          7. Additional Resources
        4. Key Points
      3. 3. Measure Twice, Cut Once: Upstream Prerequisites
        1. 3.1. Importance of Prerequisites
          1. Do Prerequisites Apply to Modern Software Projects?
          2. Causes of Incomplete Preparation
          3. Utterly Compelling and Foolproof Argument for Doing Prerequisites Before Construction
            1. Appeal to Logic
            2. Appeal to Analogy
            3. Appeal to Data
            4. Boss-Readiness Test
        2. 3.2. Determine the Kind of Software You're Working On
          1. Iterative Approaches' Effect on Prerequisites
          2. Choosing Between Iterative and Sequential Approaches
        3. 3.3. Problem-Definition Prerequisite
        4. 3.4. Requirements Prerequisite
          1. Why Have Official Requirements?
          2. The Myth of Stable Requirements
          3. Handling Requirements Changes During Construction
        5. 3.5. Architecture Prerequisite
          1. Typical Architectural Components
            1. Program Organization
            2. Major Classes
            3. Data Design
            4. Business Rules
            5. User Interface Design
            6. Resource Management
            7. Security
            8. Performance
            9. Scalability
            10. Interoperability
            11. Internationalization/Localization
            12. Input/Output
            13. Error Processing
            14. Fault Tolerance
            15. Architectural Feasibility
            16. Overengineering
            17. Buy-vs.-Build Decisions
            18. Reuse Decisions
            19. Change Strategy
            20. General Architectural Quality
        6. 3.6. Amount of Time to Spend on Upstream Prerequisites
        7. Additional Resources
          1. Requirements
          2. Software Architecture
          3. General Software-Development Approaches
        8. Key Points
      4. 4. Key Construction Decisions
        1. 4.1. Choice of Programming Language
          1. Language Descriptions
            1. Ada
            2. Assembly Language
            3. C
            4. C++
            5. C#
            6. Cobol
            7. Fortran
            8. Java
            9. JavaScript
            10. Perl
            11. PHP
            12. Python
            13. SQL
            14. Visual Basic
        2. 4.2. Programming Conventions
        3. 4.3. Your Location on the Technology Wave
          1. Example of Programming into a Language
        4. 4.4. Selection of Major Construction Practices
        5. Key Points
    7. II. Creating High-Quality Code
      1. 5. Design in Construction
        1. 5.1. Design Challenges
          1. Design Is a Wicked Problem
          2. Design Is a Sloppy Process (Even If it Produces a Tidy Result)
          3. Design Is About Tradeoffs and Priorities
          4. Design Involves Restrictions
          5. Design Is Nondeterministic
          6. Design Is a Heuristic Process
          7. Design Is Emergent
        2. 5.2. Key Design Concepts
          1. Software's Primary Technical Imperative: Managing Complexity
            1. Accidental and Essential Difficulties
            2. Importance of Managing Complexity
            3. How to Attack Complexity
          2. Desirable Characteristics of a Design
          3. Levels of Design
            1. Level 1: Software System
            2. Level 2: Division into Subsystems or Packages
            3. Level 3: Division into Classes
            4. Level 4: Division into Routines
            5. Level 5: Internal Routine Design
        3. 5.3. Design Building Blocks: Heuristics
          1. Find Real-World Objects
          2. Form Consistent Abstractions
          3. Encapsulate Implementation Details
          4. Inherit—When Inheritance Simplifies the Design
          5. Hide Secrets (Information Hiding)
            1. Secrets and the Right to Privacy
            2. An Example of Information Hiding
            3. Two Categories of Secrets
            4. Barriers to Information Hiding
            5. Value of Information Hiding
          6. Identify Areas Likely to Change
            1. Anticipating Different Degrees of Change
          7. Keep Coupling Loose
            1. Coupling Criteria
            2. Kinds of Coupling
          8. Look for Common Design Patterns
          9. Other Heuristics
            1. Aim for Strong Cohesion
            2. Build Hierarchies
            3. Formalize Class Contracts
            4. Assign Responsibilities
            5. Design for Test
            6. Avoid Failure
            7. Choose Binding Time Consciously
            8. Make Central Points of Control
            9. Consider Using Brute Force
            10. Draw a Diagram
            11. Keep Your Design Modular
          10. Summary of Design Heuristics
          11. Guidelines for Using Heuristics
        4. 5.4. Design Practices
          1. Iterate
          2. Divide and Conquer
          3. Top-Down and Bottom-Up Design Approaches
            1. Argument for Top Down
            2. Argument for Bottom Up
            3. No Argument, Really
          4. Experimental Prototyping
          5. Collaborative Design
          6. How Much Design Is Enough?
          7. Capturing Your Design Work
        5. 5.5. Comments on Popular Methodologies
        6. Additional Resources
          1. Software Design, General
          2. Software Design Theory
          3. Design Patterns
          4. Design in General
          5. Standards
        7. Key Points
      2. 6. Working Classes
        1. 6.1. Class Foundations: Abstract Data Types (ADTs)
          1. Example of the Need for an ADT
          2. Benefits of Using ADTs
          3. More Examples of ADTs
          4. Handling Multiple Instances of Data with ADTs in Non-Object-Oriented Environments
          5. ADTs and Classes
        2. 6.2. Good Class Interfaces
          1. Good Abstraction
          2. Good Encapsulation
        3. 6.3. Design and Implementation Issues
          1. Containment ("has a" Relationships)
          2. Inheritance ("is a" Relationships)
            1. Multiple Inheritance
            2. Why Are There So Many Rules for Inheritance?
          3. Member Functions and Data
          4. Constructors
        4. 6.4. Reasons to Create a Class
          1. Classes to Avoid
          2. Summary of Reasons to Create a Class
        5. 6.5. Language-Specific Issues
        6. 6.6. Beyond Classes: Packages
        7. Additional Resources
          1. Classes in General
          2. C++
          3. Java
          4. Visual Basic
        8. Key Points
      3. 7. High-Quality Routines
        1. 7.1. Valid Reasons to Create a Routine
          1. Operations That Seem Too Simple to Put Into Routines
          2. Summary of Reasons to Create a Routine
        2. 7.2. Design at the Routine Level
        3. 7.3. Good Routine Names
        4. 7.4. How Long Can a Routine Be?
        5. 7.5. How to Use Routine Parameters
        6. 7.6. Special Considerations in the Use of Functions
          1. When to Use a Function and When to Use a Procedure
          2. Setting the Function's Return Value
        7. 7.7. Macro Routines and Inline Routines
          1. Limitations on the Use of Macro Routines
          2. Inline Routines
        8. Key Points
      4. 8. Defensive Programming
        1. 8.1. Protecting Your Program from Invalid Inputs
        2. 8.2. Assertions
          1. Building Your Own Assertion Mechanism
          2. Guidelines for Using Assertions
        3. 8.3. Error-Handling Techniques
          1. Robustness vs. Correctness
          2. High-Level Design Implications of Error Processing
        4. 8.4. Exceptions
        5. 8.5. Barricade Your Program to Contain the Damage Caused by Errors
          1. Relationship Between Barricades and Assertions
        6. 8.6. Debugging Aids
          1. Don't Automatically Apply Production Constraints to the Development Version
          2. Introduce Debugging Aids Early
          3. Use Offensive Programming
          4. Plan to Remove Debugging Aids
        7. 8.7. Determining How Much Defensive Programming to Leave in Production Code
        8. 8.8. Being Defensive About Defensive Programming
        9. Additional Resources
          1. Security
          2. Assertions
          3. Exceptions
        10. Key Points
      5. 9. The Pseudocode Programming Process
        1. 9.1. Summary of Steps in Building Classes and Routines
          1. Steps in Creating a Class
          2. Steps in Building a Routine
        2. 9.2. Pseudocode for Pros
        3. 9.3. Constructing Routines by Using the PPP
          1. Design the Routine
          2. Code the Routine
          3. Check the Code
          4. Clean Up Leftovers
          5. Repeat Steps as Needed
        4. 9.4. Alternatives to the PPP
        5. Key Points
    8. III. Variables
      1. 10. General Issues in Using Variables
        1. 10.1. Data Literacy
          1. The Data Literacy Test
          2. Additional Resources on Data Types
        2. 10.2. Making Variable Declarations Easy
          1. Implicit Declarations
        3. 10.3. Guidelines for Initializing Variables
        4. 10.4. Scope
          1. Localize References to Variables
          2. Keep Variables "Live" for as Short a Time as Possible
            1. Measuring the Live Time of a Variable
          3. General Guidelines for Minimizing Scope
          4. Comments on Minimizing Scope
        5. 10.5. Persistence
        6. 10.6. Binding Time
        7. 10.7. Relationship Between Data Types and Control Structures
        8. 10.8. Using Each Variable for Exactly One Purpose
        9. Key Points
      2. 11. The Power of Variable Names
        1. 11.1. Considerations in Choosing Good Names
          1. The Most Important Naming Consideration
          2. Problem Orientation
          3. Optimum Name Length
          4. The Effect of Scope on Variable Names
          5. Computed-Value Qualifiers in Variable Names
          6. Common Opposites in Variable Names
        2. 11.2. Naming Specific Types of Data
          1. Naming Loop Indexes
          2. Naming Status Variables
          3. Naming Temporary Variables
          4. Naming Boolean Variables
          5. Naming Enumerated Types
          6. Naming Constants
        3. 11.3. The Power of Naming Conventions
          1. Why Have Conventions?
          2. When You Should Have a Naming Convention
          3. Degrees of Formality
        4. 11.4. Informal Naming Conventions
          1. Guidelines for a Language-Independent Convention
          2. Guidelines for Language-Specific Conventions
            1. C Conventions
            2. C++ Conventions
            3. Java Conventions
            4. Visual Basic Conventions
          3. Mixed-Language Programming Considerations
          4. Sample Naming Conventions
        5. 11.5. Standardized Prefixes
          1. User-Defined Type Abbreviations
          2. Semantic Prefixes
          3. Advantages of Standardized Prefixes
        6. 11.6. Creating Short Names That Are Readable
          1. General Abbreviation Guidelines
          2. Phonetic Abbreviations
          3. Comments on Abbreviations
        7. 11.7. Kinds of Names to Avoid
        8. Key Points
      3. 12. Fundamental Data Types
        1. 12.1. Numbers in General
        2. 12.2. Integers
        3. 12.3. Floating-Point Numbers
        4. 12.4. Characters and Strings
          1. Strings in C
        5. 12.5. Boolean Variables
        6. 12.6. Enumerated Types
          1. If Your Language Doesn't Have Enumerated Types
        7. 12.7. Named Constants
        8. 12.8. Arrays
        9. 12.9. Creating Your Own Types (Type Aliasing)
          1. Why Are the Examples of Creating Your Own Types in Pascal and Ada?
          2. Guidelines for Creating Your Own Types
        10. Key Points
      4. 13. Unusual Data Types
        1. 13.1. Structures
        2. 13.2. Pointers
          1. Paradigm for Understanding Pointers
            1. Location in Memory
            2. Knowledge of How to Interpret the Contents
          2. General Tips on Pointers
          3. C++-Pointer Pointers
          4. C-Pointer Pointers
        3. 13.3. Global Data
          1. Common Problems with Global Data
          2. Reasons to Use Global Data
          3. Use Global Data Only as a Last Resort
          4. Using Access Routines Instead of Global Data
            1. Advantages of Access Routines
            2. How to Use Access Routines
          5. How to Reduce the Risks of Using Global Data
        4. Additional Resources
        5. Key Points
    9. IV. Statements
      1. 14. Organizing Straight-Line Code
        1. 14.1. Statements That Must Be in a Specific Order
        2. 14.2. Statements Whose Order Doesn't Matter
          1. Making Code Read from Top to Bottom
          2. Grouping Related Statements
        3. Key Points
      2. 15. Using Conditionals
        1. 15.1. if Statements
          1. Plain if-then Statements
          2. Chains of if-then-else Statements
        2. 15.2. case Statements
          1. Choosing the Most Effective Ordering of Cases
          2. Tips for Using case Statements
        3. Key Points
      3. 16. Controlling Loops
        1. 16.1. Selecting the Kind of Loop
          1. When to Use a while Loop
            1. Loop with Test at the Beginning
            2. Loop with Test at the End
          2. When to Use a Loop-With-Exit Loop
            1. Normal Loop-With-Exit Loops
            2. Abnormal Loop-With-Exit Loops
          3. When to Use a for Loop
          4. When to Use a foreach Loop
        2. 16.2. Controlling the Loop
          1. Entering the Loop
          2. Processing the Middle of the Loop
          3. Exiting the Loop
            1. Exiting Loops Early
          4. Checking Endpoints
          5. Using Loop Variables
          6. How Long Should a Loop Be?
        3. 16.3. Creating Loops Easily—From the Inside Out
        4. 16.4. Correspondence Between Loops and Arrays
        5. Key Points
      4. 17. Unusual Control Structures
        1. 17.1. Multiple Returns from a Routine
        2. 17.2. Recursion
          1. Example of Recursion
          2. Tips for Using Recursion
        3. 17.3. goto
          1. The Argument Against gotos
          2. The Argument for gotos
          3. The Phony goto Debate
          4. Error Processing and gotos
            1. Comparison of the Approaches
          5. gotos and Sharing Code in an else Clause
          6. Summary of Guidelines for Using gotos
        4. 17.4. Perspective on Unusual Control Structures
        5. Additional Resources
          1. Returns
          2. gotos
        6. Key Points
      5. 18. Table-Driven Methods
        1. 18.1. General Considerations in Using Table-Driven Methods
          1. Two Issues in Using Table-Driven Methods
        2. 18.2. Direct Access Tables
          1. Days-in-Month Example
          2. Insurance Rates Example
          3. Flexible-Message-Format Example
          4. Logic-Based Approach
          5. Object-Oriented Approach
          6. Table-Driven Approach
          7. Fudging Lookup Keys
        3. 18.3. Indexed Access Tables
        4. 18.4. Stair-Step Access Tables
        5. 18.5. Other Examples of Table Lookups
        6. Key Points
      6. 19. General Control Issues
        1. 19.1. Boolean Expressions
          1. Using true and false for Boolean Tests
          2. Making Complicated Expressions Simple
          3. Forming Boolean Expressions Positively
          4. Using Parentheses to Clarify Boolean Expressions
          5. Knowing How Boolean Expressions Are Evaluated
          6. Writing Numeric Expressions in Number-Line Order
          7. Guidelines for Comparisons to 0
          8. Common Problems with Boolean Expressions
        2. 19.2. Compound Statements (Blocks)
        3. 19.3. Null Statements
        4. 19.4. Taming Dangerously Deep Nesting
          1. Summary of Techniques for Reducing Deep Nesting
        5. 19.5. A Programming Foundation: Structured Programming
          1. The Three Components of Structured Programming
            1. Sequence
            2. Selection
            3. Iteration
        6. 19.6. Control Structures and Complexity
          1. How Important Is Complexity?
          2. General Guidelines for Reducing Complexity
            1. How to Measure Complexity
            2. What to Do with Your Complexity Measurement
          3. Other Kinds of Complexity
        7. Key Points
    10. V. Code Improvements
      1. 20. The Software-Quality Landscape
        1. 20.1. Characteristics of Software Quality
        2. 20.2. Techniques for Improving Software Quality
          1. Development Process
          2. Setting Objectives
        3. 20.3. Relative Effectiveness of Quality Techniques
          1. Percentage of Defects Detected
          2. Cost of Finding Defects
          3. Cost of Fixing Defects
        4. 20.4. When to Do Quality Assurance
        5. 20.5. The General Principle of Software Quality
        6. Additional Resources
          1. Relevant Standards
        7. Key Points
      2. 21. Collaborative Construction
        1. 21.1. Overview of Collaborative Development Practices
          1. Collaborative Construction Complements Other Quality-Assurance Techniques
          2. Collaborative Construction Provides Mentoring in Corporate Culture and Programming Expertise
          3. Collective Ownership Applies to All Forms of Collaborative Construction
          4. Collaboration Applies As Much Before Construction As After
        2. 21.2. Pair Programming
          1. Keys to Success with Pair Programming
          2. Benefits of Pair Programming
        3. 21.3. Formal Inspections
          1. What Results Can You Expect from Inspections?
          2. Roles During an Inspection
          3. General Procedure for an Inspection
            1. Fine-Tuning the Inspection
          4. Egos in Inspections
          5. Inspections and Code Complete
          6. Inspection Summary
        4. 21.4. Other Kinds of Collaborative Development Practices
          1. Walk-Throughs
            1. What Results Can You Expect from a Walk-Through?
          2. Code Reading
          3. Dog-and-Pony Shows
        5. Comparison of Collaborative Construction Techniques
        6. Additional Resources
          1. Pair Programming
          2. Inspections
          3. Relevant Standards
        7. Key Points
      3. 22. Developer Testing
        1. 22.1. Role of Developer Testing in Software Quality
          1. Testing During Construction
        2. 22.2. Recommended Approach to Developer Testing
          1. Test First or Test Last?
          2. Limitations of Developer Testing
        3. 22.3. Bag of Testing Tricks
          1. Incomplete Testing
          2. Structured Basis Testing
          3. Data-Flow Testing
            1. Combinations of Data States
          4. Equivalence Partitioning
          5. Error Guessing
          6. Boundary Analysis
            1. Compound Boundaries
          7. Classes of Bad Data
          8. Classes of Good Data
          9. Use Test Cases That Make Hand-Checks Convenient
        4. 22.4. Typical Errors
          1. Which Classes Contain the Most Errors?
          2. Errors by Classification
          3. Proportion of Errors Resulting from Faulty Construction
          4. How Many Errors Should You Expect to Find?
          5. Errors in Testing Itself
        5. 22.5. Test-Support Tools
          1. Building Scaffolding to Test Individual Classes
          2. Diff Tools
          3. Test-Data Generators
          4. Coverage Monitors
          5. Data Recorder/Logging
          6. Symbolic Debuggers
          7. System Perturbers
          8. Error Databases
        6. 22.6. Improving Your Testing
          1. Planning to Test
          2. Retesting (Regression Testing)
          3. Automated Testing
        7. 22.7. Keeping Test Records
          1. Personal Test Records
          2. Additional Resources
          3. Testing
          4. Test Scaffolding
          5. Test First Development
          6. Relevant Standards
        8. Key Points
      4. 23. Debugging
        1. 23.1. Overview of Debugging Issues
          1. Role of Debugging in Software Quality
          2. Variations in Debugging Performance
          3. Defects as Opportunities
          4. An Ineffective Approach
            1. The Devil's Guide to Debugging
            2. Debugging by Superstition
        2. 23.2. Finding a Defect
          1. The Scientific Method of Debugging
            1. Stabilize the Error
            2. Locate the Source of the Error
          2. Tips for Finding Defects
            1. Brute-Force Debugging
          3. Syntax Errors
        3. 23.3. Fixing a Defect
        4. 23.4. Psychological Considerations in Debugging
          1. How "Psychological Set" Contributes to Debugging Blindness
          2. How "Psychological Distance" Can Help
        5. 23.5. Debugging Tools—Obvious and Not-So-Obvious
          1. Source-Code Comparators
          2. Compiler Warning Messages
          3. Extended Syntax and Logic Checking
          4. Execution Profilers
          5. Test Frameworks/Scaffolding
          6. Debuggers
        6. Additional Resources
        7. Key Points
      5. 24. Refactoring
        1. 24.1. Kinds of Software Evolution
          1. Philosophy of Software Evolution
        2. 24.2. Introduction to Refactoring
          1. Reasons to Refactor
          2. Reasons Not to Refactor
        3. 24.3. Specific Refactorings
          1. Data-Level Refactorings
          2. Statement-Level Refactorings
          3. Routine-Level Refactorings
          4. Class Implementation Refactorings
          5. Class Interface Refactorings
          6. System-Level Refactorings
        4. 24.4. Refactoring Safely
          1. Bad Times to Refactor
        5. 24.5. Refactoring Strategies
        6. Additional Resources
        7. Key Points
      6. 25. Code-Tuning Strategies
        1. 25.1. Performance Overview
          1. Quality Characteristics and Performance
          2. Performance and Code Tuning
            1. Program Requirements
            2. Program Design
            3. Class and Routine Design
            4. Operating-System Interactions
            5. Code Compilation
            6. Hardware
            7. Code Tuning
        2. 25.2. Introduction to Code Tuning
          1. The Pareto Principle
          2. Old Wives' Tales
          3. When to Tune
          4. Compiler Optimizations
        3. 25.3. Kinds of Fat and Molasses
          1. Common Sources of Inefficiency
          2. Relative Performance Costs of Common Operations
        4. 25.4. Measurement
          1. Measurements Need to Be Precise
        5. 25.5. Iteration
        6. 25.6. Summary of the Approach to Code Tuning
        7. Additional Resources
          1. Performance
          2. Algorithms and Data Types
        8. Key Points
      7. 26. Code-Tuning Techniques
        1. 26.1. Logic
          1. Stop Testing When You Know the Answer
          2. Order Tests by Frequency
          3. Compare Performance of Similar Logic Structures
          4. Substitute Table Lookups for Complicated Expressions
          5. Use Lazy Evaluation
        2. 26.2. Loops
          1. Unswitching
          2. Jamming
          3. Unrolling
          4. Minimizing the Work Inside Loops
          5. Sentinel Values
          6. Putting the Busiest Loop on the Inside
          7. Strength Reduction
        3. 26.3. Data Transformations
          1. Use Integers Rather Than Floating-Point Numbers
          2. Use the Fewest Array Dimensions Possible
          3. Minimize Array References
          4. Use Supplementary Indexes
            1. String-Length Index
            2. Independent, Parallel Index Structure
          5. Use Caching
        4. 26.4. Expressions
          1. Exploit Algebraic Identities
          2. Use Strength Reduction
          3. Initialize at Compile Time
          4. Be Wary of System Routines
          5. Use the Correct Type of Constants
          6. Precompute Results
          7. Eliminate Common Subexpressions
        5. 26.5. Routines
          1. Rewrite Routines Inline
        6. 26.6. Recoding in a Low-Level Language
        7. 26.7. The More Things Change, the More They Stay the Same
        8. Additional Resources
        9. Key Points
    11. VI. System Considerations
      1. 27. How Program Size Affects Construction
        1. 27.1. Communication and Size
        2. 27.2. Range of Project Sizes
        3. 27.3. Effect of Project Size on Errors
        4. 27.4. Effect of Project Size on Productivity
        5. 27.5. Effect of Project Size on Development Activities
          1. Activity Proportions and Size
          2. Programs, Products, Systems, and System Products
          3. Methodology and Size
        6. Additional Resources
        7. Key Points
      2. 28. Managing Construction
        1. 28.1. Encouraging Good Coding
          1. Considerations in Setting Standards
          2. Techniques for Encouraging Good Coding
          3. The Role of This Book
        2. 28.2. Configuration Management
          1. What Is Configuration Management?
          2. Requirements and Design Changes
          3. Software Code Changes
          4. Tool Versions
          5. Machine Configurations
          6. Backup Plan
          7. Additional Resources on Configuration Management
        3. 28.3. Estimating a Construction Schedule
          1. Estimation Approaches
          2. Estimating the Amount of Construction
          3. Influences on Schedule
          4. Estimation vs. Control
          5. What to Do If You're Behind
          6. Additional Resources on Software Estimation
        4. 28.4. Measurement
          1. Additional Resources on Software Measurement
        5. 28.5. Treating Programmers as People
          1. How Do Programmers Spend Their Time?
          2. Variation in Performance and Quality
            1. Individual Variation
            2. Team Variation
          3. Religious Issues
          4. Physical Environment
          5. Additional Resources on Programmers as Human Beings
        6. 28.6. Managing Your Manager
          1. Additional Resources on Managing Construction
          2. Relevant Standards
        7. Key Points
      3. 29. Integration
        1. 29.1. Importance of the Integration Approach
        2. 29.2. Integration Frequency—Phased or Incremental?
          1. Phased Integration
          2. Incremental Integration
          3. Benefits of Incremental Integration
        3. 29.3. Incremental Integration Strategies
          1. Top-Down Integration
          2. Bottom-Up Integration
          3. Sandwich Integration
          4. Risk-Oriented Integration
          5. Feature-Oriented Integration
          6. T-Shaped Integration
          7. Summary of Integration Approaches
        4. 29.4. Daily Build and Smoke Test
          1. What Kinds of Projects Can Use the Daily Build Process?
          2. Continuous Integration
        5. Additional Resources
          1. Integration
          2. Incrementalism
        6. Key Points
      4. 30. Programming Tools
        1. 30.1. Design Tools
        2. 30.2. Source-Code Tools
          1. Editing
            1. Integrated Development Environments (IDEs)
            2. Multiple-File String Searching and Replacing
            3. Diff Tools
            4. Merge Tools
            5. Source-Code Beautifiers
            6. Interface Documentation Tools
            7. Templates
            8. Cross-Reference Tools
            9. Class Hierarchy Generators
          2. Analyzing Code Quality
            1. Picky Syntax and Semantics Checkers
            2. Metrics Reporters
          3. Refactoring Source Code
            1. Refactorers
            2. Restructurers
            3. Code Translators
          4. Version Control
          5. Data Dictionaries
        3. 30.3. Executable-Code Tools
          1. Code Creation
            1. Compilers and Linkers
            2. Build Tools
            3. Code Libraries
            4. Code-Generation Wizards
            5. Setup and Installation
            6. Preprocessors
          2. Debugging
          3. Testing
          4. Code Tuning
            1. Execution Profilers
            2. Assembler Listings and Disassemblers
        4. 30.4. Tool-Oriented Environments
        5. 30.5. Building Your Own Programming Tools
          1. Project-Specific Tools
          2. Scripts
        6. 30.6. Tool Fantasyland
        7. Additional Resources
        8. Key Points
    12. VII. Software Craftsmanship
      1. 31. Layout and Style
        1. 31.1. Layout Fundamentals
          1. Layout Extremes
          2. The Fundamental Theorem of Formatting
          3. Human and Computer Interpretations of a Program
          4. How Much Is Good Layout Worth?
          5. Layout as Religion
          6. Objectives of Good Layout
            1. How to Put the Layout Objectives to Use
        2. 31.2. Layout Techniques
          1. White Space
          2. Parentheses
        3. 31.3. Layout Styles
          1. Pure Blocks
          2. Emulating Pure Blocks
          3. Using begin-end Pairs (Braces) to Designate Block Boundaries
          4. Endline Layout
          5. Which Style Is Best?
        4. 31.4. Laying Out Control Structures
          1. Fine Points of Formatting Control-Structure Blocks
          2. Other Considerations
        5. 31.5. Laying Out Individual Statements
          1. Statement Length
          2. Using Spaces for Clarity
          3. Formatting Continuation Lines
          4. Using Only One Statement Per Line
          5. Laying Out Data Declarations
        6. 31.6. Laying Out Comments
        7. 31.7. Laying Out Routines
        8. 31.8. Laying Out Classes
          1. Laying Out Class Interfaces
          2. Laying Out Class Implementations
          3. Laying Out Files and Programs
        9. Additional Resources
        10. Key Points
      2. 32. Self-Documenting Code
        1. 32.1. External Documentation
        2. 32.2. Programming Style as Documentation
        3. 32.3. To Comment or Not to Comment
        4. 32.4. Keys to Effective Comments
          1. Kinds of Comments
            1. Repeat of the Code
            2. Explanation of the Code
            3. Marker in the Code
            4. Summary of the Code
            5. Description of the Code's Intent
            6. Information That Cannot Possibly Be Expressed by the Code Itself
          2. Commenting Efficiently
          3. Optimum Number of Comments
        5. 32.5. Commenting Techniques
          1. Commenting Individual Lines
            1. Endline Comments and Their Problems
            2. When to Use Endline Comments
          2. Commenting Paragraphs of Code
          3. Commenting Data Declarations
          4. Commenting Control Structures
          5. Commenting Routines
          6. Commenting Classes, Files, and Programs
            1. General Guidelines for Class Documentation
            2. General Guidelines for File Documentation
            3. The Book Paradigm for Program Documentation
        6. 32.6. IEEE Standards
          1. Software-Development Standards
          2. Software Quality-Assurance Standards
          3. Management Standards
          4. Overview of Standards
        7. Additional Resources
        8. Key Points
      3. 33. Personal Character
        1. 33.1. Isn't Personal Character Off the Topic?
        2. 33.2. Intelligence and Humility
        3. 33.3. Curiosity
        4. 33.4. Intellectual Honesty
        5. 33.5. Communication and Cooperation
        6. 33.6. Creativity and Discipline
        7. 33.7. Laziness
        8. 33.8. Characteristics That Don't Matter As Much As You Might Think
          1. Persistence
          2. Experience
          3. Gonzo Programming
        9. 33.9. Habits
        10. Additional Resources
        11. Key Points
      4. 34. Themes in Software Craftsmanship
        1. 34.1. Conquer Complexity
        2. 34.2. Pick Your Process
        3. 34.3. Write Programs for People First, Computers Second
        4. 34.4. Program into Your Language, Not in It
        5. 34.5. Focus Your Attention with the Help of Conventions
        6. 34.6. Program in Terms of the Problem Domain
          1. Separating a Program into Levels of Abstraction
            1. Level 0: Operating-System Operations and Machine Instructions
            2. Level 1: Programming-Language Structures and Tools
            3. Level 2: Low-Level Implementation Structures
            4. Level 3: Low-Level Problem-Domain Terms
            5. Level 4: High-Level Problem-Domain Terms
          2. Low-Level Techniques for Working in the Problem Domain
        7. 34.7. Watch for Falling Rocks
        8. 34.8. Iterate, Repeatedly, Again and Again
        9. 34.9. Thou Shalt Rend Software and Religion Asunder
          1. Software Oracles
          2. Eclecticism
          3. Experimentation
        10. Key Points
      5. 35. Where to Find More Information
        1. 35.1. Information About Software Construction
        2. 35.2. Topics Beyond Construction
          1. Overview Material
          2. Software-Engineering Overviews
          3. Other Annotated Bibliographies
        3. 35.3. Periodicals
          1. Lowbrow Programmer Magazines
          2. Highbrow Programmer Journals
          3. Special-Interest Publications
            1. Professional Publications
            2. Popular-Market Publications
        4. 35.4. A Software Developer's Reading Plan
          1. Introductory Level
          2. Practitioner Level
          3. Professional Level
        5. 35.5. Joining a Professional Organization
    13. Bibliography
    14. Index
    15. About the Author

Product information

  • Title: Code Complete, 2nd Edition
  • Author(s): Steve McConnell
  • Release date: June 2004
  • Publisher(s): Cisco Press
  • ISBN: 9780735619678