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










