A Record with Named Fields
A record associates names with a defined set of fields describing one object, observation, or result.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Choose field names with meaning
An RGB sample might have red, green, and blue values. A map makes names explicit, and a record type can additionally restrict which fields are expected. Structured results use the same idea to connect an outcome with its reason.
Test a missing field
A supplied color containing only red and blue needs a declared policy for green. Use explicit rejection or a default chosen by the format. Typed input records can validate each field at the parsing boundary.[1]
Use names to make same-type fields distinguishable
With the raw pair (125, 40), a consumer may not know whether it represents width then height or the reverse. A named record can expose those names and include the unit in documentation. Test a non-square example and verify the returned values by field name. If dimensions are always positive, validate that requirement where records enter the model. See values with units.
Determine what equality means for records
Two records with equal dimensions may still represent separate objects if each has a durable identity. Comparing all record fields produces a different relation from comparing IDs. A newly added diagnostic flag should not accidentally change the business rule for equal dimensions. Define which equality relation is used at each call site. Test one pair with different IDs and equal measurements, then change only a descriptive field. See records and value equality.