Skip to content
aipatterns.dev

Category

Organizing Data

Techniques that turn raw fields, magic values, arrays and type codes into objects and types that carry meaning and protect their own invariants.

What these techniques solve

Data that is only strings, numbers and loose arrays spreads its rules everywhere. Every caller re-validates an email, remembers that index 2 is the currency, or checks type === 3. These techniques give data a proper home: small value objects, encapsulated fields and collections, named constants, and real types in place of codes.

Make illegal states hard to represent and put the rules for a value next to the value.

Members

How to choose within this category

See also

Original writing and examples. Topic coverage follows Refactoring.Guru, which explains this topic with its own illustrations.