News for hackers. Stuff that matters.
Re:Names are not type safety by p1necone on Sunday November 01, 2020 @09:36PM (#24964391)
This is an approach I've used in C#/Java - you have 'UnvalidatedFoo' and 'ValidatedFoo' types, UnvalidatedFoo has a public constructor, ValidatedFoo has a private constructor.

The only way to acquire a ValidatedFoo is to pass an UnvalidatedFoo into ValidateFoo(). The outer layer of the code deals in UnvalidatedFoos, but past that point you must have a ValidatedFoo to continue.

Re:Names are not type safety by dodobirdlord on Sunday November 01, 2020 @09:57PM (#24964462)
An extremely good example I've found for this is canonicalization in all forms. Frequently there are scenarios where there are many ways to represent something, but only one official Right Way.

https://en.wikipedia.org/wiki/Canonicalization#Usage_cases