Open
Description
For example:
someFunction(specificSpecialStrings: someRawStrings.map(SpecialString.init))
Here, it's impossible to tell if you're creating the correct kinds of special strings; the special string type is assumed by the compiler.
Consider, instead, an architecture where SpecialString
is a protocol
that types can conform to, instead of a struct
with a marker generic type associated with it:
someFunction(specificSpecialStrings: someRawStrings.map(Username.init))
Here it's clear that we're creating special Username
strings. The compiler still assumes some stuff for us so it's not any more or less verbose, but it's obvious to maintainers and peer reviewers what's intended here.