liveBook · Manning

Update function

As explained in Data-Oriented Programming: Reduce software complexity

A function that returns a new version of structured data by applying a supplied transformation to a value at a specified path.

Repeatedly fetching a value, calculating a replacement, and setting it back makes small data changes feel surprisingly tedious. An update function packages that pattern: give it structured data, a path, and a transformation; it returns a new version with the transformed value. section 14.1

Design the abstraction from its intended use:

  • Rewrite the business operation as if update already existed. section 14.1
  • Pass the transformation as an argument so update remains generic rather than encoding one business rule. section 14.1

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains the usage-first design and implementation sequence, without extending beyond a basic generic helper.
Examples
Demonstrates removing duplicate authors and doubling an income value at named paths.
What it assumes
Assumes familiarity with maps, functions, named paths, and basic Lodash-style get/set operations.
What you can do after
Build it from scratch as a generic helper that accepts the data, path, and value transformation.
How it connects
Connects maps, paths, transformation functions, and Lodash get/set utilities.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.