News for hackers. Stuff that matters.
Re:Names are not type safety (2020) by RossBencina on Monday August 04, 2025 @06:08PM (#44791877)
I was thinking of you as on the domain modelling side (same side I am usually on).

You are right, I should have gone further with the example and used Customer{ age: Age, name: PersonName}.

Re:Names are not type safety (2020) by b_e_n_t_o_n on Tuesday August 05, 2025 @06:05AM (#44796233)
Why not go further? Customer should be a subtype of Human, which contains subtypes DoesInteractWithCompany and HasNeverHeardOfUs. Customer should have subtypes for each country they live in, and PersonName should probably be split into FullName<FirstName, LastName> for flexibility.
Re:Names are not type safety (2020) by RossBencina on Wednesday August 06, 2025 @06:29AM (#44810212)
The purpose of a model is to represent salient features of a domain (both the data, behavior, constraints.) In the context of this discussion we are particularly interested in modelling behavior and constraints. As your examples illustrate, it is possible to do a poor job, e.g. model at the incorrect level of abstraction (Human is not salient unless you have a concrete need to model Customer's of other Species), or to introduce specious abstractions. The fact that forming useful domain models is non-trival does not render it worthless.