liveBook · Manning

Calculation phase

As explained in Data-Oriented Programming: Reduce software complexity

The calculation phase is the phase of a mutation that computes the next version of system data without advancing the current state.

The calculation phase computes the next version of system data without changing the current state. A mutation separates this stateless work from the stateful commit phase, which advances the system-state reference afterward. section 4.0 section 4.8

The calculation phase is characterized by:

  • Using immutable functions to create a new data version rather than modifying received data. section 4.8
  • Remaining stateless and specific to the mutation, while common commit code manages the state reference. section 4.0
  • Computing in isolation under optimistic concurrency control; reconciliation or abortion belongs to the commit phase. section 5.1

Adding a library member

Library.addMember reads the current user-management data, creates a new version containing the member, places it into a new library version, and returns that version. The current library remains unchanged until the commit phase advances the system-state reference. section 4.5

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 implementation specificity. section 4.0

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains immutable updates, structural sharing, and isolated concurrency computation, while leaving state advancement to the commit phase.
Examples
Demonstrates Library.addMember producing a new library version before SystemState.commit updates the active reference.
What you can do after
Build mutations with immutable functions that calculate a next version before a separate commit updates system state.
How it connects
Connects immutable data, structural sharing, the commit phase, state management, and optimistic 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.