Fair point, but I’m also not arguing for “valid at all times”, as that’s impossible. However, I think that’s for the most part, pure semantics. I’m a subscriber to the DDD approach where the business domain cannot be ALLOWED to have an invalid state at any time. This is enforced by strong typing and/or validation where required. This massively reduces bugs, and so my point about IDs and value objects are approaches to enforcing that validity of state.
I think arguing against that doesn’t make much sense, but of course you will have invalid state when a use submits a form, for example, and you have to manage that, but that’s a separate concern. It seems to me to be a bit of a strawman, honestly, or at least somewhat disingenuous - because it’s obvious. You can’t enforce valid state from a user, that’s why we have validation in place to begin with.
Your point about the ID part, what you’re suggesting simply wouldn’t be possible. The value object pattern enforces that (for example), the ID must be an integer, or a ULID, or whatever it is that makes sense in your system. Of course, a developer could certainly just create an id object without an actual valid id value, but the question then needs to be asked - why? Why are you doing this? If it’s for testing purposes, okay - makes sense. But are you doing this in code you’re preparing for production? Bigger questions would need to be answereed there, likely one of maliciousness ![]()






















