More often than not, when we use the language’s primitives, ...

More often than not, when we use the language’s primitives, we give up an opportunity to express the domain model of our application. When we use a String to represent an Email, we haven’t encoded the fact that it needs to satisfy some constraints (ex: have an @, or satisfy a regular expression, or have a finite length). When we use Hash to represent structured data, we allow the possibility that some keys will be unset, or that some other keys will have values. We can fix all these problems by using classes specific for our use-cases.

You probably want to express you’re own version of a primitive in the context of what you’re building. Even if basically meaningless at first, it allows for better reasoning by the programmer.

Say it with me: if no illegal states can be represented, we never have to worry about the validity of our objects.

www.joshbeckman.org/notes/669505324