this post was submitted on 25 Aug 2025
23 points (100.0% liked)

Programming

24153 readers
335 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

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.

top 3 comments
sorted by: hot top controversial new old
[–] jbrains@sh.itjust.works 6 points 4 months ago

I have settled into this pattern:

  1. Name expands as I understand better the structural role of a thing. Duplication in names begins to become easier to spot.
  2. Removing duplication in names means introducing helpful structures, resulting in shortening names again, particularly as the intent/purpose of thing becomes clearer.

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".)

[–] TehPers@beehaw.org 4 points 4 months ago* (last edited 4 months ago)

Though in some contexts, I might prefer a name like employeeToRole for a Map<Employee, Role> over the article's employeeRoles.

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 or req or res are clear with context, but output, request, and response 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:

let response = foo();
let response = validate_response(response);

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.

[–] GrumpyBike1020@monero.town 1 points 4 months ago

Great writeup! I shared with my devs