liveBook · Manning

Concrete type

As explained in Data-Oriented Programming in Java

A data type whose representation and permitted values directly encode a particular meaning.

A concrete type makes a value’s domain meaning visible in its representation. A variable declared as String may contain anything, while UUID communicates that the identifier has UUID semantics and excludes unrelated values. section 1.2

From vague identifier to meaningful type

String id permits values such as "Hello World!", "2024-05-04", or an IP address. Replacing it with UUID aligns the code with the stated meaning of the identifier and narrows the states the program can express. section 1.2

Concrete types improve a design by:

  • Exposing domain knowledge directly in code instead of leaving readers to infer it from names, documentation, or runtime data. section 1.2
  • Reducing ambiguity caused by flags, nulls, or assignments whose meaning changes according to surrounding conditions. section 1.7
  • Making illegal states impossible to express when the chosen representation matches the domain. section 1.7
Listing 1.3 Changing how we represent that one line
String id
UUID id  #A

Compare the vague String declaration with the more communicative UUID declaration, alongside invalid identifier examples. section 1.2

How Data-Oriented Programming in Java covers it

How deep it goes
Contrasts vague and concrete representations, stopping short of detailed construction or validation mechanics.
Examples
Uses an unadorned String identifier, invalid identifier literals, and a UUID replacement.
What it assumes
Assumes familiarity with Java variables and types while teaching why representation communicates domain semantics.
What you can do after
Evaluate and improve data models by replacing imprecise representations with types that express domain meaning.
How it connects
Connects data representation with data-oriented programming, object-oriented programming, domain modeling, and illegal-state prevention.

Also explained in

Compare how 4 books explain concrete type →

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.