Data written out to send

Think of it when data leaves one program for a file, a database or another program.

In everyday life

Flat-pack furniture: the factory takes the wardrobe apart and writes instructions, and you rebuild it at home. If you read the instructions differently from how they were meant, you build a different wardrobe.

One case

An airline’s server sends each flight date to its phone app as text: “03/04”. The server means 3 April. The app reads the text month first and shows 4 March. A test with 5 May passed, because “05/05” reads the same both ways.

The server wrote day first; the app read month first
The case, cell by cell1 cell = 1 flight
Date of the flight
3 Apr12 Apr5 May13 May1 Jun7 Jun
Date the app shows
4 Mar4 Dec5 Mayerror6 Jan6 Jul
Flights with a wrong date
5
Flights that look fine
1
One date reads the same both ways, so a quick test passed.

Every case

Programs cannot share memory across a network, so every message is written out as text or bytes and read back on the other side. Both sides must agree on the format. Dates, decimal numbers and missing values are common places where they disagree.

The word

Engineers call this

serialization, JSONTurning data in a program into text or bytes so it can be saved or sent, and turning it back on the other side. JSONA plain text format for data, such as {“total”: 25.5}. Many web programs send data this way. is a common format.

Every time data crosses between programs, it is written out and read back. Agree the format, and test the round trip.

Where this idea leads

Skills that encode it

  • principle-boundary-discipline pstack“Parse raw data into domain types at the boundary”, so a misread format fails where the data enters.
  • principle-type-system-discipline pstack“External data is untyped until parsed”: JSON and other payloads get a parse function at every boundary.