liveBook · Manning

Code-first approach

As explained in Data-Oriented Programming in Java

A code-first approach is a software development approach that begins by implementing a representation before fully investigating the domain meaning of the data.

A code-first approach starts by implementing a representation before fully investigating what the data means. Developers often map visible JSON shapes mechanically: text becomes String, numbers become int or double, and the result looks precise before its domain semantics are understood. section 3.1

A measurement with hidden meaning

A drying-oil measurement may contain a sample identifier, elapsed days, and contact angle. A first Java translation is record Measurement(String sampleId, int daysElapsed, double contactAngle) {}. Returning to the data then exposes unanswered questions: elapsed days include zero and may be sparse, while contact angle has a bounded degree range and hundredth-degree precision. section 3.1

Use the approach as a starting point, then interrogate each representation:

  • Ask “what does this mean?” repeatedly, beginning with the most basic question about each domain idea. section 3.1
  • Record discovered constraints explicitly instead of leaving them hidden behind primitive fields. section 3.1
Listing 3.2 A mechanical translation from JSON to Java
record Measurement(           
  String sampleId,         #A
  int daysElapsed,         #A
  double contactAngle      #A
) {}

Inspect the mechanical JSON-to-Java translation, then compare each field with the domain notes to find missing semantics. section 3.1

How Data-Oriented Programming in Java covers it

How deep it goes
Descends from primitive field mapping to explicit domain constraints, but stops before showing their final type-safe encoding.
Examples
Uses JSON and Java records to model drying-oil measurements, then documents elapsed-day and contact-angle constraints.
What you can do after
Evaluate representations by questioning field meanings and recording domain constraints before treating primitive mappings as final.
How it connects
Connects domain modeling with the type system, Java records, JSON, and domain semantics.

Also explained in

Compare how 5 books explain code-first approach →

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.