Re:Value Objects – DDD with TypeScript
by stemmlerjs on Wednesday April 10, 2019 @02:43PM
(#19627584)
That's pretty funny. I like that. Yeah, I'd say it definitely depends on your project and your team.
There are also ways to opt-in and out of following rules like this, even from a TypeScript context- you just have to be more aggressive about it.
For example, you could access private methods by doing:
User['create']() for example. Sometimes this is necessary for testing.
I do believe it's better to be strict but allow a loophole just in case future use requires it.
For example in my codebase, only valid objects can be created via User.create but we do create invalid ones for testing since it's not necessary to have full objects there.