Skip to main content

Module 3: Code Readability Basics

Primary teacher: this guide
Selective supporting text: Clean Code (Robert C. Martin)

This is a small orientation module, not the complete Clean Code course. It establishes habits that a beginning programmer can apply immediately: reveal intent with names, keep functions honest, use comments for context rather than narration, format code for reading, and protect behavior with basic tests.

The complete book and the deeper questions about object design, system boundaries, refactoring strategy, and review heuristics belong to Semester 3: Software Design & Patterns. On the full-book path, read Clean Code there, after Good Code, Bad Code, and read it critically rather than as unquestionable law.


Required Scope​

Work through these concepts in order.

Readability Foundations​

OrderConceptFocus
1Clean Code Is a Change StrategyWhy readability lowers the cost of future changes
2Names Carry Design IntentIntention-revealing names and honest distinctions
3Comments Are a Last ResortWhen comments help and when clearer code is better
4Formatting Shapes How Code Is ReadLayout as communication rather than decoration

Honest Functions and Basic Tests​

OrderConceptFocus
5Functions Should Do One ThingSingle purpose and one level of abstraction
6Arguments and Side Effects Must Be HonestInputs, mutation, and unsurprising behavior
7Tests Enable Design ChangeTests as protection for small structural changes
8Tests Should Read Like ExplanationsClear test names and one behavior per test

Then complete these practice pages:

  1. Diagnose Readability Debt
  2. Refactor a Function Without Lying
  3. Use Tests to Unlock Design Changes

Use the module quiz after the required concepts and practice. The exercise lanes, learning resources, and selective reading map are optional support when the guide is not enough.


Deferred to Semester 3​

Semester 0 deliberately does not require:

  • error-handling and third-party boundary design
  • emergent design rules and broader duplication tradeoffs
  • object/data distinctions, cohesion, SOLID, and class responsibility
  • system seams and dependency control
  • formal refactoring workflows, smell catalogs, and full code-review heuristics
  • front-to-back reading of Clean Code

Semester 3 teaches those ideas with stronger prerequisites and compares Clean Code against Refactoring, Good Code, Bad Code, OOAD, and the design-pattern texts.


Learning Objectives​

By the end of this module you should be able to:

  1. Explain how readability affects the cost and risk of change.
  2. Improve names, comments, and formatting with a concrete reason for each change.
  3. Refactor a small function so its purpose, inputs, and side effects are clear.
  4. Write basic behavior tests that make a small refactor safer.

Outputs​

  • one readability audit of an existing file
  • one small function refactored in verified steps
  • one small behavior-focused test suite
  • one short before/after note explaining what became easier to understand

Completion Standard​

You are done when you can improve a small piece of code without relying on vague claims such as “this looks cleaner,” and your tests demonstrate that its behavior stayed intact.

Suggested Flow​

SessionWork
1Concepts 1-4 and a readability audit
2Concepts 5-6 and a function-level refactor
3Concepts 7-8, behavior tests, and the module quiz

Rich Learning Pages​

Worked Examples | Guided Labs | Case Studies | Mistake Clinic | Reading Guide | Capstone Thread