3 ms·
> I've seen people create classes containing only a string That can be a good way to improve type-checking in code that would otherwise pass around bare string
by DougBTX 9y ago
> I've seen people create classes containing only a string
That can be a good way to improve type-checking in code that would otherwise pass around bare strings. It reduces the chances that e.g. a plain text string is confused with an HTML string.
If your language supports it, an opaque type alias would be more explicit:
https://flow.org/en/docs/types/opaque-types/ https://flow.org/en/docs/types/opaque-types/
- raverbashing 9y agoYes, if the auxiliary class either checks or transforms the string in some way I agree But that's in specific cases, not all cases