this post was submitted on 28 Mar 2024
616 points (98.1% liked)

Programmer Humor

32561 readers
488 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] hstde@feddit.de 70 points 8 months ago (3 children)

This is something that can easily get refactored, because the purpose of alia the variables is right there in the name. This is way better that spending three days to try to figure out what the purpose of var1 is.

[–] jballs@sh.itjust.works 7 points 8 months ago (1 children)

Nah, refactoring this would be a bitch. Your function name contains everything that happens in the function. Which means if you add something to it, you also have to change the name of the function. So CallThisWhenThePlayerTakesDamageAndIfThePlayerHealthIsLessThanZeroThenAlsoTheyDie would have to go to something like CallThisWhenThePlayerTakesDamageAndIfThePlayerHealthIsLessThanZeroThenAlsoTheyDieAndIncrementTheTotalDamageTakenCounter if you added something else.

[–] Hotzilla@sopuli.xyz 11 points 8 months ago

IDE renames all references, no issue

[–] princess@lemmy.blahaj.zone 6 points 8 months ago

oh such hope

in a week IntegerThatTracksOneThingForOnePurpose will be an object tracking 30% of the game state and mutated in 15 places without ever being renamed

[–] lorty@lemmygrad.ml 1 points 8 months ago

Then they change what the function does without updating the name and you misunderstand the code completely.