News for hackers. Stuff that matters.
Re:How Developers Choose Names by 3grdlurker on Sunday April 18, 2021 @10:30AM (#26852780)
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.
Re:How Developers Choose Names by TechBro8615 on Sunday April 18, 2021 @12:03PM (#26853594)
> may have some internal checks that could eventually call something like updateDate

This sounds like exactly the kind of pre-mature optimization that leads to overly-abstract function names throughout the codebase. Your point is a good one, once the function does something more than `updateDate()`. But until then, just call it `updateDate()`. As a bonus, this way any time you do choose to use `handleClick()`, the name is conspicuous enough that you pause to see what side effects it might have.

Re:How Developers Choose Names by 3grdlurker on Tuesday April 20, 2021 @11:32AM (#26876004)
It’s not premature optimization, it’s just boilerplate because it’s a pattern that happens so often.

Besides, there’ll be less work if the requirements do in fact change, and there’s nothing wrong with accounting for the possibility of change when you’re writing code because what you write now constrains what you can write in the future.

Re:How Developers Choose Names by city41 on Sunday April 18, 2021 @11:10AM (#26853122)
I agree. It's also nice to know when you see a `handle` function, it is getting slotted into an `on` somewhere. Within the handle I prefer to call functions such as updateDate().

But this whole thread brings up something about coding that has always irked me, it's very opinion based. When two people strongly hold the opposite opinions on the same team, it can be a massive hassle for absolutely zero benefit.

Re:How Developers Choose Names by hinkley on Sunday April 18, 2021 @11:45AM (#26853429)
It also quickly explains to you that no, you can’t refactor this method to change the arguments.
Re:How Developers Choose Names by DrSiemer on Sunday April 18, 2021 @12:04PM (#26853608)
In training interns I had to figure out what part of my coding advice to them is best practice and what part is just the way I like to do things.

It's good to know the difference and it gave them the space to challenge me on some of those methods, which in turn helped me write better code.

Re:How Developers Choose Names by nitrogen on Sunday April 18, 2021 @04:20PM (#26855948)
When two people strongly hold the opposite opinions on the same team, it can be a massive hassle for absolutely zero benefit.

On teams, or in life in general, IMO when there is no consensus, or even an anti-consensus, the only rational global decision is not to make a global decision.

Re:How Developers Choose Names by kuang_eleven on Sunday April 18, 2021 @09:38PM (#26858368)
I cannot disagree strongly enough, this is how you end up working on teams that are just disconnected, hostile fiefdoms.

Solving an issue that is intractable via discussion is when you escalate. Probably to a tech lead, or even to a manager.

Re:How Developers Choose Names by nitrogen on Monday April 19, 2021 @04:27PM (#26867591)
Maybe we're talking about different kinds of issues. In the context of opinion-based disagreements (rather than matters of fact or evidence), an anti-consensus seems to indicate that there isn't (and can't be) one right answer. If one group imposes its will on another group, or appeals to the powers that be to do so on their behalf, the second group will definitely become hostile to the first. Thus, anything other than "agreeing to disagree" and moving on to areas where you do agree would just build more resentful, disconnected hostility.
Re:How Developers Choose Names by hanniabu on Sunday April 18, 2021 @10:50AM (#26852977)
Personally I would have both and within the handleClick() function do whatever it needs to do and call an atomic updateDate() function (assuming it's updating the date globally). Although for anything generalized standalone function I like to put that in its own namespace, such as helper.updateDate().
Re:How Developers Choose Names by dapids on Sunday April 18, 2021 @11:10AM (#26853127)
Or be explicit. Call it AtomicUpdateDate if such functionality is really desired. Nobody should assume any operation is atomic ... Unless it is explicitly stated to be so.

EDIT: sorry meant to reply to the parent comment.

Re:How Developers Choose Names by granshaw on Sunday April 18, 2021 @10:39AM (#26852865)
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 by jbluepolarbear on Sunday April 18, 2021 @10:50AM (#26852978)
I take this approach as well; especially, when the handle takes an event param and can then let the object react with the correct behaviour.
Re:How Developers Choose Names by throwawayboise on Sunday April 18, 2021 @05:55PM (#26856829)
validateAndUpdateDate()