Long Names Are Long
(journal.stuffwithstuff.com)
from shape_warrior_t@programming.dev to programming@programming.dev on 25 Aug 20:12
https://programming.dev/post/36315990
from shape_warrior_t@programming.dev to programming@programming.dev on 25 Aug 20:12
https://programming.dev/post/36315990
A nice little reminder that clarity is not the same as verbosity. Also has some concrete tips for removing unnecessary verbosity in names, complete with examples. Though in some contexts, I might prefer a name like employeeToRole
for a Map<Employee, Role>
over the article’s employeeRoles
.
threaded - newest
Great writeup! I shared with my devs
Following the article, the former describes the type (a map from employees to roles) while the latter describes the relationship (these are the employees’ roles).
At the same time, I’m not pedantic enough to care in practice. Both are fine, and I’ll get the point when I read either of those.
I agree with the author here that names don’t need to be so verbose, but I also think there needs to be a balance.
out
orreq
orres
are clear with context, butoutput
,request
, andresponse
are always clear and not bad to write.http_response
adds extra unnecessary info (unless there’s another response variable in scope).It also helps when languages support local variable shadowing. For example:
Both of these are responses, and fundamentally the same thing being passed around while being mutated. The types are (potentially) different. You won’t use the first variable ever again (and in Rust, likely can’t). Just reuse the name.
I have settled into this pattern:
Long names stay unnecessarily long when we don’t notice the patterns that suggest the missing structures.
The more examples of this kind of thing, the better!
(And my preferred name for that is
rolesByEmployee
. In general, “values by key”.)