Primitive obsession
Also known as Primitive obsession, Primitive obsession in software engineering
Definition
A code smell in which domain concepts are represented by generic primitives instead of meaningful types.
What it means
Primitive obsession appears when strings, numbers, or booleans carry rules that belong to a domain concept. A dedicated type can validate invariants, name intent, and prevent accidental mixing. The improvement is not to wrap every value, but to give important concepts a clear home.
Example
A function accepts two strings for currency and account identifier. A money type and an account identifier type can make units and validation visible at the call site.
Limitations
Value objects add code and may complicate serialization or interoperability. A primitive is often sufficient for a local, unambiguous value. Consider repeated validation, unit confusion, and change frequency.
How to use the signal
Introduce a domain type when it protects units or invariants that recur, not when a local primitive is already unambiguous.
Weave can help compare domain-type refactors with review and rework signals. Keep type design with the owning team and use Weave to observe whether the change reduced recurring friction.
How this relates to Weave
Weave can help compare domain-type refactors with review and rework signals. Keep type design with the owning team and use Weave to observe whether the change reduced recurring friction.
Explore Engineering intelligence