I found this essay Primitive Obsession by Andrew Cairns interesting. The big example in it is this:
$user = new User('abc123', 'email@address.com');
Code language: JavaScript (javascript)
Here the User
function takes two string
params, string
being a primitive type, and here, quite easy to screw up by passing them in the wrong order and/or not pre-validating the values. If you agree, there are a variety of ways to tackle this problem which generally boil down to passing in a typed object. TypeScript and Zod fans will be like: yeah duh.
Glad you found the article interesting! 🙂