liveBook · Manning

Chapter 11: First-class functions: Part 2

What you will learn in chapter 11 of Grokking Simplicity

Introduces the chapter’s planned practice with higher-order functions, copy-on-write, and logging improvements.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces the chapter’s planned practice with higher-order functions, copy-on-write, and logging improvements.

11.1 One code smell and two refactorings

This section recaps a code smell and two refactorings for turning hard-coded values and changing behavior into first-class arguments.

Key terms: implicit argument in function name, first-class values, express implicit argument, explicit argument, first-class, replace body with callback, before, body, and after, higher-order functions

11.2 Refactoring copy-on-write

This section shows that replace body with callback can apply to the repeated steps of copy-on-write, not just repeated syntax.

Key terms: replace body with callback, copy-on-write, before, body, after

11.3 Refactoring copy-on-write for arrays

The section refactors array copy-on-write operations into a reusable function that standardizes the discipline, accommodates new array operations, and can avoid intermediate copies.

Key terms: copy-on-write, replace body with callback, withArrayCopy(), modify, copy-on-write discipline, intermediate copies

11.4 Returning functions from functions

This section shows how returning a function can turn repeated error-handling code into a reusable function factory, and when that abstraction is worth using.

Key terms: wrapLogging(), higher-order function, function factories, try/catch, Snap Errors®, inner function, return value, rest arguments, spread operator, higher-order functions

11.5 Conclusion

The conclusion links higher-order functions to the earlier distinction between actions, calculations, and data, and previews their exploration in later chapters.

11.6 Summary

11.7 Up next…

The section previews the next chapter’s exploration of functional array iteration, building on forEach().

Where this is used later

Concepts explained in this chapter

← Chapter 10: First-class functions: Part 1 Chapter 12: Functional iteration →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.