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 😱
Naming: Every Developer's Nightmare
Samuel Braun ・ Apr 18 '23
#webdev
#javascript
#programming
#tutorial
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)
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.
No, and probably you should not have one too. I recommend sticking to whatever the best practice is for your language/team/company etc.
Probably everything that is using Hungarian notation. (btw, I'm Hungarian, lol)
I'm indifferent.
I've seen this in a code base:
HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor
-javadoc
HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor
That's so long it actually breaks the docs layout on mobile.
What's the worst-named variable you've seen in the wild?
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...:
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
Do you have a favorite naming pattern for variables?
This cheatsheet will help some extend - github.com/kettanaito/naming-cheat....
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.
About naming things, I published a few weeks ago about SPA vs MPA, and their relation to CSR, SSR et al.
Naming things is hard, SPA edition
Thomas Broyer ・ Mar 28 ・ 7 min read