liveBook · Manning

Data transformation

As explained in Data-Oriented Programming in Java

Data transformation is the process of producing successive data states by changing or converting an existing representation.

A system can represent change without mutating one long-lived object. Treat each meaningful moment as data, then derive the next state from it. Like frames of a tossed ball, successive values can preserve the continuity people recognize as identity while leaving each frame available to inspect, persist, or send elsewhere. section 2.4

For domain design, a transformation is a deliberate data-in/data-out boundary: one representation enters, another leaves. Start by naming the input and output types before deciding how the arrow is implemented. This keeps attention on the business story rather than on methods, storage, or control flow. section 5.3 section 5.3.1

Turning overdue invoices into a fee

A late-fee workflow becomes clearer when its intermediate states carry meaning: List<Invoice> → List<PastDue> → LateFeeDraft → LateFeeInvoice. The PastDue type says why an invoice qualifies; Draft says the proposed invoice is not official until it reaches the billing system. Each transformation exposes a requirement that nested conditionals can hide. section 5.3.1

Listing 5.8 Refining how late fees get produced in our system
List<Invoice>            #A
-> List<PastDue>         #B
-> LateFeeInvoice        #C

Read the pipeline left to right: each arrow produces a more specific representation, making the fee rule and its prerequisite state visible. section 5.3.1

Use transformations to make a domain model easier to change:

  • Invent types freely while exploring; postpone their fields and implementation until the sequence tells the right story. section 5.3
  • Prefer representations that balance domain meaning, usability, and safety; wrapper types can record what is known about a state. section 5.9
  • At a legacy boundary, map a semantic type deterministically into the existing entity instead of reshaping the domain model around persistence. section 6.4.1 section 6.4.2

Transformation boundaries also make integration choices explicit. A LateFee can remain a well-typed domain value, then be translated to a generic Invoice only when existing repositories must save it. The mapping is tedious, but it isolates legacy assumptions and lets the newer model grow without immediately replacing surrounding machinery. section 6.4.1 section 6.4.2

How Data-Oriented Programming in Java covers it

How deep it goes
Develops transformation sequences and lifecycle states while deliberately deferring implementation details during design.
Examples
Illustrates a tossed ball's successive states and an invoice-to-late-fee pipeline with Draft and Open stages.
What it assumes
Assumes comfort designing data types and treats implementation details as unnecessary during early behavior modeling.
What you can do after
Apply it via named domain types to sketch behaviors and translate semantic values into legacy entities.
How it connects
Connects identity, lifecycle states, algebraic sum types, Data Transfer Objects, and Data Access Layers.

Also explained in

Compare how 23 books explain data transformation →

Related concepts

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