Properties5
TypeArticle
AuthorBen Hoyt
DateJul 3, 2023
URLhttps://benhoyt.com/writings/short-names/
Note createdJul 3, 2023

rw-book-cover


It’s actually easy to name things. The hard thing is naming them well. Maybe if it were harder to name them we’d spend longer choosing good names.


I’m a strong advocate of designing your module to be used with the module name as a dotted prefix. Requests follows this: get() wouldn’t make much sense on its own, but requests.get() is clean and clear. You don’t get name clashes, because the module name is right there to disambiguate.


don’t name things to explain everything they do; name things so the meaning is clear in context.


I’ll finish with a quote from Russ Cox, tech lead of the Go project, who states his variable naming philosophy this way:

A name’s length should not exceed its information content. … Global names must convey relatively more information, because they appear in a larger variety of contexts. Even so, a short, precise name can say more than a long-winded one: compare acquire and take_ownership. Make every name tell.