3

#DEVDiscuss: Naming Things

 1 year ago
source link: https://dev.to/devteam/devdiscuss-naming-things-25p4
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Top comments (8)

CollapseExpand

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.

Comment button Reply

CollapseExpand

  • 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

Comment button Reply

CollapseExpand

HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor

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

Comment button Reply

CollapseExpand

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

  • Seen this in production code:
class Foo {
    struct Bar {
    }
}
  • Who knows ?...
bool isLoaded(){...}
bool isReallyLoaded(){...}
  • "In a galaxy far away":
long long timeAgo;
  • 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;
...

Comment button Reply

CollapseExpand

  • 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

Comment button Reply

CollapseExpand

Do you have a favorite naming pattern for variables?

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

Comment button Reply

CollapseExpand

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.

Comment button Reply

CollapseExpand


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK