DEV Community

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

Posted on • Edited on

15 3 1 1 2

#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.

DEV is built on open source software called Forem!

GitHub logo forem / forem

For empowering community 🌱


Forem 🌱

For Empowering Community

Build Status Build Status GitHub commit activity GitHub issues ready for dev GitPod badge

Welcome to the Forem codebase, the platform that powersdev.to. We are so excited to have you. With your help, we canbuild out Forem’s usability, scalability, and stability to better serve ourcommunities.

What is Forem?

Forem is open source software for building communities. Communities for yourpeers, customers, fanbases, families, friends, and any other time and spacewhere people need to come together to be part of a collectiveSee our announcement postfor a high-level overview of what Forem is.

dev.to (or just DEV) is hosted by Forem. It is a community ofsoftware developers who write articles, take part in discussions, and buildtheir professional profiles. We value supportive and constructive dialogue inthe pursuit of great code and career growth for all members. The ecosystem spansfrom beginner to advanced developers, and all are welcome to find their place…

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay