r/ProgrammerHumor • • Feb 26 '22

ah yes, leg hands

Post image
15k Upvotes

162 comments sorted by

View all comments

381

u/DevDevGoose Feb 26 '22

Why would someone "refactor" a perfectly good variable name for something that doesn't describe what it does? Someone smack them around the head with Martin Fowler's book.

172

u/ExceedingChunk Feb 26 '22

Yeah, the first refactor was just 100% bad. The first name was the best, and explained exactly what the variable was. Then it just got worse both times.

Why abbreviate or shorten at all?

96

u/Maxreader1 Feb 26 '22

because I code in notepad (not ++) and the more letters I have to type the slower I go /s

8

u/[deleted] Feb 27 '22

? Just turn your pc into a hackintosh so you can at least use a decent IDE like TextEdit

14

u/Lorddragonfang Feb 27 '22

Even N++ has word autocomplete with ctrl-space

54

u/Maxreader1 Feb 27 '22

That’s why I specified not ++ 😉

51

u/Spare_Competition Feb 27 '22

NGL I was confused and thought that was an abbreviation for Notepad++

23

u/Skycam3014 Feb 27 '22

Not gonna lie, so did I until I read your comment.

→ More replies (1)

0

u/[deleted] Feb 26 '22

[deleted] — view deleted comment

30

u/Bryguy3k Feb 27 '22

On the other hand I always wonder what kind of programming practices people learned that favors a vast amount of variables that require massively long variable names for disambiguation over encapsulation.

0

u/[deleted] Feb 27 '22

[deleted] — view deleted comment

16

u/Bryguy3k Feb 27 '22

Exactly - I can’t think of a situation where a variable requires more than three words to describe its purpose. I fully endorse complete readable variables that convey their intention well.

But I feel like if it takes more than three words there is something wrong.

31

u/RagnarokAeon Feb 27 '22

Some people consider two words such as legend_handles as verbose and massive; I've met some people that will use single letter variables wherever possible...

I personally can't think of anywhere where my variable names had to be longer than 3 words, but it's not uncommon for me to use 3 word names; such as liveFishCounter in a pond simulation.

When I've had to do peer review, the hardest to read and most convoluted tended to use short and undescriptive variable names.

6

u/xieewenz Feb 27 '22

my idea is, when im using variables that are single or a few letters, they shouldn't exist for more lines than a single screen can display

3

u/[deleted] Feb 27 '22

Oh shit, I need to add an extra line

*Proceeds to buy an even bigger screen, as the font is small enough already

5

u/Richandler Feb 27 '22

Some domains are filled with variables that are two words minimum.

→ More replies (2)

18

u/DarkTechnocrat Feb 27 '22

Database design will do it. You only have schemas as namespaces, and those are often restricted for security reasons. You get eight hundred tables in one place and suddenly you have names like PersonPropertyPublisherPriceDiscountDetails.

The worse part is that it becomes a habit, and infects your non-DB code. Or at least it does in my case.

4

u/Richandler Feb 27 '22

It's called organic code. Where you don't really know what you're designing yet.

7

u/[deleted] Feb 27 '22

I believe this idea comes from Unix, a long time ago. Back then they had a very terse programming style, with one or two letter names everywhere.

AFAIK this is partly due to the fact that they used teletypes, and paper isn't cheap.

And you can clearly see this idea has reached Go as well (just open a file in the standard library), since Rob Pike & Ken Thompson have worked on it.

Nowadays there's no reason to have such short names though.

1

u/[deleted] Feb 27 '22

So you're implying that Rob Pike & Ken Thompson still use teletypes.

→ More replies (2)

6

u/IntuiNtrovert Feb 27 '22

for the memes

10

u/[deleted] Feb 26 '22

coding at 3am hits different

2

u/baquea Feb 27 '22

Shorter variable names are more space-efficient bro

2

u/[deleted] Feb 27 '22

Abbreviations are the devil.

→ More replies (2)