DEV Community

Cover image for #DEVDiscuss: Naming Things
Erin Bensinger for The DEV Team

Posted on • Edited on

#DEVDiscuss: Naming Things

image created by Margaux Peltat for the Chilled Cow YouTube channel

Time for #DEVDiscuss β€” right here on DEV 😎

Inspired by @samuel-braun's Top 7 post, tonight’s topic is...naming things 😱


Questions:

  • Do you have a favorite naming pattern for variables?
  • What's the worst-named variable you've seen in the wild? Note: comments must abide by the Code of Conduct!
  • How do you feel about naming? Love it, hate it, indifferent?
  • Any triumphs, fails, or other stories you'd like to share on this topic?

Top comments (8)

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

I take the iterative view: I choose the first non terrible thing that comes to mind, make things work, commit, look at my naming choices again, notice those that are lying and refactor them

Also when naming something very important, I explicitly ask for feedback in the PR.

Collapse
 
ervin_szilagyi profile image
Ervin Szilagyi • Edited
  • Do you have a favorite naming pattern for variables?

No, and probably you should not have one too. I recommend sticking to whatever the best practice is for your language/team/company etc.

  • What's the worst-named variable you've seen in the wild?

Probably everything that is using Hungarian notation. (btw, I'm Hungarian, lol)

  • How do you feel about naming? Love it, hate it, indifferent?

I'm indifferent.

  • Any triumphs, fails, or other stories you'd like to share on this topic?

I've seen this in a code base:

HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor -
javadoc

Collapse
 
t1xx1 profile image
Tiziano

HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor

That's so long it actually breaks the docs layout on mobile.

Collapse
 
tandrieu profile image
Thibaut Andrieu

What's the worst-named variable you've seen in the wild?

  • Seen this in production code:
class Foo {
    struct Bar {
    }
}
Enter fullscreen mode Exit fullscreen mode
  • Who knows ?...
bool isLoaded(){...}
bool isReallyLoaded(){...}
Enter fullscreen mode Exit fullscreen mode
  • "In a galaxy far away":
long long timeAgo;
Enter fullscreen mode Exit fullscreen mode
  • Any class ending with "Manager". They are always just a bunch of methods that do stuff.

  • I also have encountered that kind of pattern too many times...:

Color red = #00ff00;
int one = 2;
string windowsVersion = "Ubuntu1804";
float PI = 1.570;
...
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ressenzo profile image
Renan Cossenzo
  • Do you have a favorite naming pattern for variables?
    I like to follow c# coding conventions and always try to name anything with an explanation of what it means in the context

  • What's the worst-named variable you've seen in the wild?
    Hungarian notation (i've just found out what it is) and abbreviations (I mean: what does "r1" variable mean???)

  • How do you feel about naming? Love it, hate it, indifferent?
    I like naming. I think it is really important to be the most explicit as possible for other devs

Collapse
 
rajajaganathan profile image
Raja Jaganathan

Do you have a favorite naming pattern for variables?

This cheatsheet will help some extend - github.com/kettanaito/naming-cheat....

Collapse
 
jarvisscript profile image
Chris Jarvis

Do you have a favorite naming pattern for variables?

Personal projects Basic camel case and Noun Verb/adjective.
Work or open source work follow their guidelines.

Collapse
 
tbroyer profile image
Thomas Broyer

About naming things, I published a few weeks ago about SPA vs MPA, and their relation to CSR, SSR et al.