
How much time do you spend thinking of good identifier names? - gsaga
Sometimes I find myself getting stuck on a project just because I can&#x27;t think of a good name for a new class which implements some new feature.
How do you deal with this problem? One way I can think of is assigning template names(&#x27;NewFeature1&#x27;). It isn&#x27;t that big of a problem with modern ide&#x27;s which provide one click renames.
======
dangerface
When I am having difficulty naming things its usually because I am trying to
be too concise. In my experience its always better to be more verbose and
accurate than to spend time trying to be clever and end up with something I
don't remember what it does but its called newSlide.

------
tudelo
Honestly, I don't have a good way. It doesn't happen often but sometimes I
just end up with a 20+ character identifier. Seems to fit in fine in Java land
though. And like you, if I want to do a rename, my IDE will help me do it
better than I ever could alone.

I will note that I usually find a better name after it sits there for a while
and starts to not make sense. Also after hearing complaints from other
programmers about "why is this called x when it should be y :)".

------
swatcoder
You can often improve your identifiers, but they should come pretty easy if
you understand your task and the approach you're taking to it.

Nondescriptive "template names" (your "NewFeature1") are a _huge_ red flag
signaling unpreparedness.

While there is pressure to "just code it" that comes from methodologies like
Agile or from just having an intense workload, the spontaneity should be
happening in the context of professional expertise and good insight.

Do you have a sense of what algorithms are relevant? What traditional
patterns? What data is being represented? What transforms are being applied?
What libraries and services are being utilized? You don't need an 40 page
architecture to start coding, but you'll usually have answers to all those
questions somewhere in mind. And your identifiers should usually be pretty
obvious when you do.

------
yesenadam
Can't think of a good name? So think of a bad name for it. You will
automatically think about what's wrong with the bad name and a better one will
occur to you, etc.

Also, worrying about the perfect name at the start is extremely premature
optimization - often/usually the purpose of things changes, or you realize it
wasn't what you thought it was, or you come to understand it better, or it
gets split or combined etc.

------
gesman
Take time to think about the way/pattern you will use to name identifiers
across the whole project. Camel-cased? Lowercased with underscores? 2-4 words
in each?

After that things will be easier and faster.

