Live data from Hacker News

How Developers Choose Names

arxiv.org

31–40 of 157 posts

Re: How Developers Choose Names

#31

Earlier quoted context omitted.

I'd argue that the ability to unite people by assigning meaning onto things, places, and ideas is the single reason why humans have been so successful in advancing civilization to where it is today. Edit: eschew -> assign

Pedant note: eschew means ‘to go without’. You probably meant ‘assigning’.

Whoops, thanks

Re: How Developers Choose Names

#32
post #4

One of the most cruel things evolution did to us is that we constantly seek meaning, order, correctness, where there are none to speak of.

That awfully sounds anti-knowledge. Humans didn’t use to think that there was an order or correctness to all the facts that fall under science and mathematics today.

Re: How Developers Choose Names

#33

I have a rule called “name it what it does, not how it’s used” which is a mistake I often see with junior developers and sacrifices information density Eg it’s more helpful for readability to do “onClick => updateDate()” rather than “onClick => handleClick()” (Not the best example and I’ve seen far more egregious, but those examples are escaping me now)

I’d agree in some cases, but then you get weird debouncing code in your update date function. Because, no one wanted to change the onClick function name in 38 different places when it starts to do more.

If you don't have refactoring that can rename functions across your code base, now you have two problems

Re: How Developers Choose Names

#34

I have a rule called “name it what it does, not how it’s used” which is a mistake I often see with junior developers and sacrifices information density Eg it’s more helpful for readability to do “onClick => updateDate()” rather than “onClick => handleClick()” (Not the best example and I’ve seen far more egregious, but those examples are escaping me now)

I completely agree with this, but I additionally advocate for function/method names to be formed verb-object. Plus IMHO active, descriptive verbs are best, instead of 'do', 'handle', or 'manage'. As others have mentioned, handle click might be appropriate as a shim/landing point for satisfying an interface. Logic is best when focused without unnecessary dependencies/side effects. The best naming comes along with a strong design and architecture, when all the pieces can justify their existence and boil down to the essence of what the system is trying to accomplish.

Re: How Developers Choose Names

#35

I have a rule called “name it what it does, not how it’s used” which is a mistake I often see with junior developers and sacrifices information density Eg it’s more helpful for readability to do “onClick => updateDate()” rather than “onClick => handleClick()” (Not the best example and I’ve seen far more egregious, but those examples are escaping me now)

I’m an engineering lead and I made a rule of using the handleClick() style instead of updateDate() in our codebase. The reasoning is that the latter sounds more like an atomic, standalone function, whereas handleClick() may have some internal checks that could eventually call something like updateDate(), but the internal checks are beyond the responsibility of the updateDate() function.

Yes my example was if updateDate literally just updates the date - I take this a step further too, Eg if the function has some extra checks, I’ll name it maybeDoX(), which is a somewhat uncommon practice in common programming languages

Re: How Developers Choose Names

#36

I have a rule called “name it what it does, not how it’s used” which is a mistake I often see with junior developers and sacrifices information density Eg it’s more helpful for readability to do “onClick => updateDate()” rather than “onClick => handleClick()” (Not the best example and I’ve seen far more egregious, but those examples are escaping me now)

I’d agree in some cases, but then you get weird debouncing code in your update date function. Because, no one wanted to change the onClick function name in 38 different places when it starts to do more.

onClick => onAccept => submitRequest

The downside is lots of little functions, the plus side is smaller behaviors. (Ie avoiding 5 levels of nesting in a single function.)

Re: How Developers Choose Names

#37
post #9

I would be interested if any task-performance based studies had been run with different naming schemes and enough developers to see which naming conventions worked best. Some simple job like fixing a bug or a simple refactoring, judged on time to completion and correctness.

That would be great empirical data to see. However from anecdotal data across almost two decades, is extremely obvious to my case study that naming is second only to application architecture in its impact on ease or difficulty and risk of updating the code base in the future.

Re: How Developers Choose Names

#38
post #27

Earlier quoted context omitted.

I'd argue that the ability to unite people by assigning meaning onto things, places, and ideas is the single reason why humans have been so successful in advancing civilization to where it is today. Edit: eschew -> assign

That's precisely the problem. It's very useful, when it's useful. Which leaves us spinning in circles when it's not.

It would be impossible for you to say this (circular) sentence and call something a “problem” if you didn’t think that there was some basis of right/wrong, which contradicts your top-level comment.

Re: How Developers Choose Names

#40

Earlier quoted context omitted.

I’d agree in some cases, but then you get weird debouncing code in your update date function. Because, no one wanted to change the onClick function name in 38 different places when it starts to do more.

If you don't have refactoring that can rename functions across your code base, now you have two problems

In 16 years as a developer, I have never seen this beyond the scope of a single project/language. Once things cross boundaries it stops.
Post reply on HN