Primitive Obsession: Introduce Domain Types
Primitive obsession is using a plain string or number for an idea that has its own rules, so every method that touches it must remember those rules. A domain type is a small type for one such idea, and a value object is one compared by its value. These lessons take an account service where the email rule lives in three methods and has already drifted, give the email and the customer ID their own types, and turn a new email rule into one edit.
Pick your language
When to use it
A value has rules, like a format or a normal form, that more than one method checks, or two values of the same type are easy to swap.
A string has no rules and passes through once, like a free-text delivery note.
The same check or conversion in several methods, several strings in one signature, names that carry a format like emailLower.