Design Patterns · Middle · Question 33 of 75
What is primitive obsession, and how is it treated?
- ✓Correct answer: Domain concepts are bare strings and numbers; treated with value types
- 2Using
numberinstead ofbigintfor large numbers - 3Giving up classes in favor of functions and primitives
Explanation
userId: string, price: number are easy to confuse with other strings and numbers. Value objects (Money), branded TS types (UserId) and enum-like unions make such mistakes impossible and gather validation in one place.