Follow

Pet peeve of mine: overly descriptive variable names.

Calling a request "r" is perfectly fine, especially if its used often throughout that function! Relying on idioms can make code more readable, not less. Obviously there are exceptions to this, but I just hate the kneejerk reaction that many people have when they see one or two letter variable names.

If you can't tell, I come from a C/Go/Maths background.

· · Web · 1 · 0 · 0

This mini-rant stems from a code review (not mine) recently where a colleague suggested that the parameter in a 5-line equals(Object o) method should be renamed something more descriptive. Now to me, calling a parameter that just refers to *another object* without any real intrinsic meaning "o" is as idiomatic as calling a loop index "i".

I'm not talking about global variables. Those should be namespaced and have descriptive names and documentation.

But local variables that are used throughout a function? Let the usage describe it, not the name. I want to be able to fit 2-3 files split vertically on my screen at once and not have to worry about wrapping and horizontal scrolling.

Even globals, I'm okay with aliasing them locally if they're going to be used repeatedly, for example `const w = os.windows;`

Sign in to participate in the conversation
Mathstodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!