Domain semantics are the meanings and validity rules assigned to concepts in a problem domain. The integer 4 becomes data when it represents a temperature, age, or voltage; its domain meaning determines what the value means and which uses are valid. section 2.8
Discovering semantics requires asking what something is, rather than merely recording how it is represented. A field’s character pattern describes syntax, but understanding its meaning requires identifying the concepts inside it and the invariants they impose. section 3.1.1 section 3.1.2
From sample identifier to domain model
A Sample ID initially appears to be an alphanumeric string such as "UV-1". Deeper analysis reveals that it is a pair: a curing method, restricted to AIR, UV, or HEAT, and a non-negative sample number. Those meanings become invariants rather than assumptions hidden in strings. section 3.1.1
Listing 3.6 Incomplete domain analysis
Domain Notes.md
=========================================================
SampleID:
Alpha-numeric + special characters
Days Elapsed:
A positive integer (0 inclusive)
Not strictly daily. Will be Sparse
Contact Angle:
Degrees from -180° (inclusive) to 180° (exclusive)
Precision of 100th of a degreeUse the domain notes as a starting checklist: record representations and ranges, then continue questioning until the concepts and invariants behind them are explicit. section 3.1.1
Once meaning is understood, encode it in types and validation. Records and value classes provide concise representations, while constructors can reject or transform invalid input. Strong modeling aligns the meaning of a type with the meaning of its data, making incorrect states difficult to create. section 2.8 section 3.6
