3 ms·
I don't like the old style NSDictionary way of packing information that so many API's use. First of all they're lacking an enforcement for the type of the value
by dep_b 9y ago
I don't like the old style NSDictionary way of packing information that so many API's use. First of all they're lacking an enforcement for the type of the value they're expecting (sometimes leading to crashes if you get them wrong) and the discoverability of possibilities is less easy than with a struct or object.
Still, passing in password twice would still be a possible mistake. The only thing that would help in my opinion would be types that can be applied to primitives, a bit like F# does. So you can declare certain Doubles to be Miles, Kilometers, Meters and so on. Or a certain type of string can be of type DatabaseID or a Password.
- pducks32 9y agoYea I was thinking about this too! We can talk all day about static typing vs productivity but if they had a basic string type called PasswordHint and Password then maybe (maybe!) this wouldn’t happen.
- UnoriginalGuy 9y agoI'd leave passwordHint as a string; but password... That might be an interesting type. Particularly if it zeroed out memory as a freebie in the destructor. Actually that was my take-away from this article, the "maybe in MY projects I should wrap passwords in a special type to stop me typo-ing the raw password to output."