News for hackers. Stuff that matters.
Re:Value Objects – DDD with TypeScript by true_religion on Monday April 08, 2019 @02:42AM (#19602707)
Well you could use the Python approach of "we are all adults" and allow people to do the wrong thing if they are explicitly asking to do it.

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.

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.