Architecture

Objects should be constructed in one go

Matthias Noback—who has managed to blog consistently every week this year 😯—shares his experience applying “consistency” rules to his objects.
When you create an object, it should be complete, consistent and valid in one go.
In the post, a geolocation service gets a refactoring treatment. Matthias goes through multiple iterations, each with their own tradeoffs.
It is derived from the more general principle that it should not be possible for an object to exist in an inconsistent state. I think this is a very important rule, one that will gradually lead everyone from the swamps of those dreaded “anemic” domain models. However, the question still remains: what does all of this mean?
Despite the title, the beauty of this article isn’t in a quick guideline, but in the refactoring process that we get guided through.