Code reuse means using existing code in multiple places or contexts instead of duplicating its implementation. Smaller functions are easier to reuse because they do less and make fewer assumptions. section 5.7 section 9.18
Use these design rules to make reuse more likely:
- Pull concerns apart into small functions that can be composed again. section 5.7
- Extract functions into lower layers of a stratified design; code with fewer functions underneath it is more reusable. section 9.18 section 9.19
- Prefer named callbacks over inline callbacks when a smaller function can serve more than one context. section 13.3 section 13.2
Extracting reusable callbacks
A customer-processing chain becomes more reusable when inline callbacks are named: filter(customers, isGoodCustomer) and map(bestCustomers, getBiggestPurchase). isGoodCustomer works on one customer, while the surrounding selection function only works on an array. The smaller function can therefore be applied in other contexts. section 13.3 section 13.2
Use the figure to visualize how lower layers create opportunities for reuse and how call-graph depth affects it. section 9.18





