A few days ago I read the blog post Parse, don’t type-check and liked it, you should read it.
Over the past year I’ve been doing a lot of reading about software architecture and this is something that comes up a lot. We must try to write programs that prevents us from representing data that makes no sense or is in some way invalid.
For this I’ve been using value objects. They are simple to understand, immutable and composable. The great thing about value objects is that if you have an instance, you know the data they hold is valid.