A data carrier is a small, explicit structure for holding and communicating a defined set of values. Model the data before writing behavior, name its meaning, keep its invariants nearby, and prefer immutability when mutation is unnecessary. section 4.3
Make intent visible
Replace a generic User or a bare numeric value with a meaningful structure such as PhysicalProfile or WeightInPounds. Likewise, represent a composite key, range, unit, or short-lived method result explicitly when the structure improves understanding without creating needless complexity. section 4.3
Use a data carrier when it earns its place by reducing ambiguity or protecting meaning:
- Keep validation rules near the data they protect and reject invalid states early. section 4.3
- Use clearer types when several same-typed arguments can be swapped, and use enums for fixed categories. section 4.3
- Flatten deeply nested structures where a simpler model, such as a composite key, communicates more clearly. section 4.3
