Lesson 1 of 5 | Modeling Values and State
Records Are Value Syntax, Not Automatic Value Objects
Interview frame
C# records provide value-oriented equality and concise non-destructive mutation, but a domain value object still needs valid construction, stable invariants, and an intentional equality boundary.
Example
public sealed record Money(decimal Amount, string Currency); compares components, yet it accepts negative values and inconsistent currency casing. A stronger type validates and normalizes in a factory or constructor. If a record contains a mutable list, the record can appear unchanged while the list changes, and equality uses the list reference rather than sequence contents.
Design questions
- Which components define identity?
- Can any component change after construction?
- Is normalization part of the invariant?
- Will the object be used as a dictionary key?
The best interview answer distinguishes language-provided mechanics from domain guarantees.