liveBook · Manning

Multi-version state management

As explained in Data-Oriented Programming: Reduce software complexity

Multi-version state management maintains multiple immutable versions of system data and advances a reference to select the current version.

Multi-version state management keeps system data immutable while allowing a mutable reference to select the current version. Instead of changing a hash map in place, each mutation produces a new version, then advances the state reference. Structural sharing reuses unchanged data, avoiding an expensive deep copy. section 4.1 section 4.8

A mutation separates the risky work from the small stateful boundary:

Undoing a committed mutation

Suppose systemData points to V12 and previousSystemData to V11. Committing a mutation advances them to V13 and V12. Undoing the mutation makes systemData point back to V12, reusing the retained immutable version rather than reconstructing it. section 4.7

Table 4.1 The two phases of a mutation (view table figure)

Phase

Responsibility

State

Implementation

Calculation

Computes the next version of system data

Stateless

Specific

Commit

Moves the system state forward

Stateful

Common

Compare calculation and commit by responsibility, statefulness, and whether their implementation is specific or common. section 4.0

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains structural sharing, phase separation, central validation, and undo, but assumes mutations do not occur concurrently.
Examples
Uses hash-map mutations, version transitions from V12 to V13, undo references, and a SystemState implementation.
What it assumes
Assumes hash-map-based system data while teaching immutability, structural sharing, mutation phases, and state references.
What you can do after
Build it from scratch with immutable updates, shared versions, a validating commit boundary, and a simple undo reference.
How it connects
Connects immutable data, structural sharing, mutations, validation, undo, and concurrency control.

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.