3 ms·
Empty String Considered Harmful
- cratermoon 5y agoBetter yet, instead of working around the limitations of primitive types like string, make firstName, lastName, and nickName instances of a type Name that knows how to handle the zero value, then change the code that prints the full name to use an aggregate type FullName composed of all the Names and give it the ability to represent itself. Oh, and given international considerations, don't use "first" and "last", prefer "given name" and "surname". See for example https://wiki.c2.com/?PrimitiveObsession https://wiki.c2.com/?PrimitiveObsession
- _samjarman 5y agoOh for sure, just an example to demonstrate the compiler coming to the party to help out. Definitely not a person class tutorial haha! Thanks for your link though, interesting read!