Design Patterns · Middle · Question 33 of 75

What is primitive obsession, and how is it treated?

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.

Further reading

Problem with a question

Design Patterns · Middle · question 33

Test yourself

Take the Design Patterns · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz