Books & Videos

Table of Contents

  1. Chapter 1 Code Should Be Easy to Understand

    1. What Makes Code “Better”?

    2. The Fundamental Theorem of Readability

    3. Is Smaller Always Better?

    4. Does Time-Till-Understanding Conflict with Other Goals?

    5. The Hard Part

  2. Surface-Level Improvements

    1. Chapter 2 Packing Information into Names

      1. Choose Specific Words
      2. Avoid Generic Names Like tmp and retval
      3. Prefer Concrete Names over Abstract Names
      4. Attaching Extra Information to a Name
      5. How Long Should a Name Be?
      6. Use Name Formatting to Convey Meaning
      7. Summary
    2. Chapter 3 Names That Can’t Be Misconstrued

      1. Example: Filter()
      2. Example: Clip(text, length)
      3. Prefer min and max for (Inclusive) Limits
      4. Prefer first and last for Inclusive Ranges
      5. Prefer begin and end for Inclusive/Exclusive Ranges
      6. Naming Booleans
      7. Matching Expectations of Users
      8. Example: Evaluating Multiple Name Candidates
      9. Summary
    3. Chapter 4 Aesthetics

      1. Why Do Aesthetics Matter?
      2. Rearrange Line Breaks to Be Consistent and Compact
      3. Use Methods to Clean Up Irregularity
      4. Use Column Alignment When Helpful
      5. Pick a Meaningful Order, and Use It Consistently
      6. Organize Declarations into Blocks
      7. Break Code into “Paragraphs”
      8. Personal Style versus Consistency
      9. Summary
    4. Chapter 5 Knowing What to Comment

      1. What NOT to Comment
      2. Recording Your Thoughts
      3. Put Yourself in the Reader’s Shoes
      4. Final Thoughts—Getting Over Writer’s Block
      5. Summary
    5. Chapter 6 Making Comments Precise and Compact

      1. Keep Comments Compact
      2. Avoid Ambiguous Pronouns
      3. Polish Sloppy Sentences
      4. Describe Function Behavior Precisely
      5. Use Input/Output Examples That Illustrate Corner Cases
      6. State the Intent of Your Code
      7. “Named Function Parameter” Comments
      8. Use Information-Dense Words
      9. Summary
  3. Simplifying Loops and Logic

    1. Chapter 7 Making Control Flow Easy to Read

      1. The Order of Arguments in Conditionals
      2. The Order of if/else Blocks
      3. The ?: Conditional Expression (a.k.a. “Ternary Operator”)
      4. Avoid do/while Loops
      5. Returning Early from a Function
      6. The Infamous goto
      7. Minimize Nesting
      8. Can You Follow the Flow of Execution?
      9. Summary
    2. Chapter 8 Breaking Down Giant Expressions

      1. Explaining Variables
      2. Summary Variables
      3. Using De Morgan’s Laws
      4. Abusing Short-Circuit Logic
      5. Example: Wrestling with Complicated Logic
      6. Breaking Down Giant Statements
      7. Another Creative Way to Simplify Expressions
      8. Summary
    3. Chapter 9 Variables and Readability

      1. Eliminating Variables
      2. Shrink the Scope of Your Variables
      3. Prefer Write-Once Variables
      4. A Final Example
      5. Summary
  4. Reorganizing Your Code

    1. Chapter 10 Extracting Unrelated Subproblems

      1. Introductory Example: findClosestLocation()
      2. Pure Utility Code
      3. Other General-Purpose Code
      4. Create a Lot of General-Purpose Code
      5. Project-Specific Functionality
      6. Simplifying an Existing Interface
      7. Reshaping an Interface to Your Needs
      8. Taking Things Too Far
      9. Summary
    2. Chapter 11 One Task at a Time

      1. Tasks Can Be Small
      2. Extracting Values from an Object
      3. A Larger Example
      4. Summary
    3. Chapter 12 Turning Thoughts into Code

      1. Describing Logic Clearly
      2. Knowing Your Libraries Helps
      3. Applying This Method to Larger Problems
      4. Summary
    4. Chapter 13 Writing Less Code

      1. Don’t Bother Implementing That Feature—You Won’t Need It
      2. Question and Break Down Your Requirements
      3. Keeping Your Codebase Small
      4. Be Familiar with the Libraries Around You
      5. Example: Using Unix Tools Instead of Coding
      6. Summary
  5. Selected Topics

    1. Chapter 14 Testing and Readability

      1. Make Tests Easy to Read and Maintain
      2. What’s Wrong with This Test?
      3. Making This Test More Readable
      4. Making Error Messages Readable
      5. Choosing Good Test Inputs
      6. Naming Test Functions
      7. What Was Wrong with That Test?
      8. Test-Friendly Development
      9. Going Too Far
      10. Summary
    2. Chapter 15 Designing and Implementing a “Minute/Hour Counter”

      1. The Problem
      2. Defining the Class Interface
      3. Attempt 1: A Naive Solution
      4. Attempt 2: Conveyor Belt Design
      5. Attempt 3: A Time-Bucketed Design
      6. Comparing the Three Solutions
      7. Summary
  1. Appendix Further Reading

    1. Books on Writing High-Quality Code

    2. Books on Various Programming Topics

    3. Books of Historical Note

  2. Colophon