Good Code
The good version uses a record so the response shape is constructed with all required values and then stays stable.
Lesson 02
Use records or init-only properties for response shapes that should not change after mapping.
public sealed record ReviewSummary(
Guid Id,
string Title,
int Score
)
{
// Record data stays stable after response mapping.
public bool IsPassing => Score >= 70;
}public sealed class ReviewSummary
{
public Guid Id { get; set; }
public string Title { get; set; } = "";
public int Score { get; set; }
// Public setters let later code rewrite the response shape.
public bool IsPassing => Score >= 70;
}The good version uses a record so the response shape is constructed with all required values and then stays stable.
The bad version exposes public setters for every field. Any later code can rewrite a response after validation, mapping, or logging.