3 ms·
I've been burned far too many times by ambiguous names. The edict on hashmaps in here is a particular one that has gotten me more than once, so i always name t
by Pxtl 7y ago
I've been burned far too many times by ambiguous names. The edict on hashmaps in here is a particular one that has gotten me more than once, so i always name them "ValuesByKey" style. Alike "AccountsByID".
It's a risk/reward thing. Overlong names are annoying. Brief names are destructive. So I always err on the side of length.
- atoav 7y agoThis is one of the pros of using a strictly typed language: there errors like these can only go unnoticed if the other object has the same type. And in languages like Rust with a concept of ownership even those might be cought in compilation.. Naming things is hard. But it is a lot easier if you can rely on it not breaking things all the time.
- Pxtl 7y agoHashtables full of record-like objects are the usual problem. I often find myself throwing records into a hashtable and then keying it by one of its properties, and that means it's a simple primitive and there may be many of the same type. If I've a record with a half-dozen int properties that are semantically IDs, I have to clarify which is the key for this hashtable.