liveBook · Manning

Code readability

As explained in Grokking Simplicity

The degree to which source code can be understood by human readers.

Code readability is how easily people can understand source code. It depends on the language, libraries, legacy code, house style, and what programmers already know—not on architectural purity alone. section 18.23

Make readability a practical trade-off:

  • Choose an action over an equivalent calculation when the action is clearer in the surrounding language and codebase. section 18.23
  • Prefer clear separation between domain calculations and interaction-layer actions, often by extracting calculations. section 18.23
  • Apply new functional techniques cautiously; overuse can damage readability and maintenance until their limits are understood. section 19.4

A readable reporting pipeline

A report function reduces products into text. Enriching products with discounts before calling it makes the data transformation visible, while keeping database interaction separate from report generation. section 18.23

function generateReport(products) {
    return reduce(products, "", function(report, product) {
        return report + product.name + " " + product.price + "\n";
    });
}
 
var productsLastYear = db.fetchProducts('last year');
var productsWithDiscounts = map(productsLastYear, function(product) { #1
    if(!product.discountID)
      return product;
    return objectSet(product, 'discount', db.fetchDiscount(product.discountID));
});
var reportLastYear = generateReport(productsWithDiscounts);

Inspect the report pipeline and its explicit discount-enrichment step. section 18.23

How Grokking Simplicity covers it

How deep it goes
Explains contextual factors and refactoring direction, but stops short of defining a formal readability measurement.
Examples
Uses JavaScript-style report generation, product discount enrichment, and the progression from functional experimentation to production code.
What it assumes
Assumes existing programming conventions and functional techniques while emphasizing learning when not to apply them.
What you can do after
Evaluate implementation choices and isolate less-readable or performance-driven compromises for later cleanup.
How it connects
Connects functional programming with onion architecture, domain layers, interaction layers, maintenance, and testing-oriented refactoring.

Also explained in

Compare how 11 books explain code readability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Simplicity. The section links point to the parts of the book it draws on.