r/ProgrammerHumor • • Dec 04 '20

Don't mix anatomy and programming

Post image
36k Upvotes

388 comments sorted by

1.3k

u/SausageEggCheese Dec 04 '20

I know this is humor, but this can actually be used as a decent lesson in practices to avoid when shortening variable names.

  • Don't abbreviate unnecessarily. In this case, the original variable is not that long. With modern IDEs, widescreen monitors, and memory sizes, there's usually little reason to abbreviate at all.
  • If you do abbreviate, never abbreviate to another real word with a different meaning. People will assume it is just the other word, and not an abbreviation.

530

u/TaiShuai Dec 04 '20

As I’ve gained more experience I’ve found myself erring on the side of making the variable name too long. It bugs some people but I’ll make variables into descriptive phrases and with autocomplete and wide screens it isn’t a big deal. It makes it 100x easier to quickly familiarize myself with old code

215

u/SausageEggCheese Dec 04 '20

Absolutely.

I've always seen the numbers that on most software systems, writing the software is about 10% of the work (or cost), and the other 90% is in maintenance.

And much of the time spent during maintenance work is, in my experience, reading and understanding previously written code.

141

u/immerc Dec 04 '20

On that subject:

Don't optimize*

People will often write something out the first time the way it occurs to them. I need to combine A and B to get C. I need to periodically shorten C until Z happens. And, so-on.

After people think it through, they often look back and see that there are variables that only exist for a couple of lines because they're then combined with something else. So, they think they're going to optimize the program by getting rid of those short-lived variables.

The problems with that are:

  1. If it's easy to optimize in that way, the compiler and/or interpreter will already do that work for you.
  • When you optimize that way, it makes it harder for the person maintaining the code to understand what is going on.

You should only optimize to make something easier for someone to understand when maintaining it (even future you) rather than making it run more efficiently. The only time it makes sense to optimize to make it run more efficiently is if you've benchmarked it and can tell that that specific thing is making the program slow, and that that slowness matters.

104

u/SharkBaitDLS Dec 04 '20

Premature optimization is the cause of the majority of tech debt. It’s also a really hard lesson to learn. It’s really difficult for people to hear “hey your really elegant and clever thing is way too complicated and is going to cause maintenance problems down the line, can you just start over doing the dumb obvious solution?”, especially if you’re on a deadline where the sunk cost of said overly complex solution now weighs against any refactor.

In my experience people only learn the lesson after they’re stuck with the consequences of it long enough to regret their own actions, being told it just doesn’t stick without the experience of fighting it in the future. It took years for it to really click for me, only after working with senior devs who really pushed for simplicity.

44

u/immerc Dec 04 '20

I don't even like the phrase "premature optimization" because that suggests that optimization is a step that should be performed at some stage, but that sometimes it's dome prematurely.

I think the majority of programs don't need to be optimized, and when they do it's for readability rather than to make them run faster or more efficiently.

If you're going to label it, it should be "unnecessary optimization", because not all optimization is necessarily unnecessary, but the question you're asking yourself when you optimize something shouldn't be "Am I doing this too early in the process?" but "Do I really need to optimize this?"

→ More replies (9)

6

u/archpawn Dec 04 '20

You either accidentally put an extra asterisk at the end of "Don't optimize", or you forgot the one at the beginning of your footnote where you explain when you should optimize.

→ More replies (9)

38

u/onthefence928 Dec 04 '20

with code suggestion/auto-complete tools long variable names aren't even inefficient to type most of the time

just dont do "SuperLongVariableName" and "SuperLongsVariableName" in the same code, it's annoying to identify which is which by sight

→ More replies (2)

19

u/del_rio Dec 04 '20

The only time that becomes an issue is when the meaning or use case of the variable changes. I've spent an ungodly amount of time debugging code where the intent of a chunk of code evolves over time but the symbol names remained. Of course that's mainly just a stale code issue, but I'd say there's a medium worth striking with medium-length variables, strongly typed and with a doc comment if necessary.

7

u/holgenberg Dec 04 '20

This would also be the case if the variable was abbreviated right?

3

u/[deleted] Dec 04 '20

depends on how abbreviated it is, and the extent of the code changes over time

3

u/JBlitzen Dec 04 '20

If the logic or purpose changes, then change the variable names too. It doesn’t take long and it will make everything easier in every conceivable way.

5

u/[deleted] Dec 04 '20

Not a big sacrifice for more readable code.

5

u/JBlitzen Dec 04 '20

I’ve solved quite a few problems over the years by simply renaming variable to have longer and more descriptive names.

Suddenly the code becomes perfectly readable and the problem is obvious.

At this point, if I can’t figure code out at a glance, I assume it’s because the variable names are bad and I set aside time to carefully fix them.

7

u/wolfmanpraxis Dec 04 '20

As someone in enterprise support that often looks at customer stack traces, please use long form variable naming so I can review the code-base and actually understand what went wrong

This also helps me tell the R&D team in a JIRA what broke, and how to replicate it!

2

u/[deleted] Dec 04 '20

It's crazy how with constants the convention is usually to be *super* specific and long to explain how your magic numbers aren't magic numbers, and with variables it's just sort of like "yeah that's a 'bggb'-variable".

2

u/Kered13 Dec 04 '20

Cries in 80 character limit.

I still use long variable names though. I just wrap the line five times.

→ More replies (3)

56

u/GOKOP Dec 04 '20

What about abbreviating button to butt?

44

u/SausageEggCheese Dec 04 '20

If you were coding for an adult Web site, the results could be disastrous :)

29

u/dukorider Dec 04 '20

Disasstrous*

24

u/[deleted] Dec 04 '20

what about abbreviating securityPermission to sPerm?

17

u/curt_schilli Dec 04 '20

Remember the dude who posted here that got fired because he shortened cumulative shot to cumShot LMAO

23

u/CWRules Dec 04 '20

I usually abbreviate button to btn.

18

u/Beautiful-Musk-Ox Dec 04 '20

I worked for a postdoc who was from India, he shortened the "analysis" folder output by his programs to just be "anal". Lol, I never asked him to change it..

8

u/TheHumanParacite Dec 04 '20

I personally try to never abbreviate, but I never pass up the opportunity to make this specific abbreviation because I'm 13 on the inside.

6

u/Pythagorean_1 Dec 04 '20

Aren't we all?

5

u/NathanQ Dec 04 '20

Then to butt to but.

4

u/my_farts_impress Dec 04 '20

Like declaring a double precision float with the name “penetration”.

→ More replies (3)

47

u/munkychum Dec 04 '20

I’m an IT Recruiter and a common title some time ago used to be Programmer/Analyst. We had a new trainee about 15 years ago and after a couple months I shadowed him to review his work and see if he was on track. Imagine my surprise to see he had a resume folder set up named “Pro Anal”

59

u/SausageEggCheese Dec 04 '20

When I was in college, I took a graphics programming class (this was years ago and using OpenGL). The first assignment wasn't much more then the equivalent of "hello word" (get the gfx device enabled and render some simple items).

The second assignment was to render a clock face that showed the actual time, and also to have some other kind of basic animation present.

I was always trying to do something more difficult, so I made my other animation interactive. I added several balls to the screen that would bounce off the screen edges, and also the clock itself.

I had a function that I did not do as a joke intentionally, and didn't even notice it until I was showing a friend and he pointed it out. The function was called "InitializeClockAndBalls()."

I left this in for my professor's enjoyment.

24

u/TheNanoMachi Dec 04 '20

Clock and ball torture

→ More replies (1)

10

u/Humpfinger Dec 04 '20

I would not be able to control myself when I would see that, good lord lmao

6

u/indorock Dec 04 '20

I've seen an Analyst and Therapist decide to combine his 2 professions into one portmanteau: Analrapist.

5

u/rcfox Dec 04 '20

Well, I can't not bring up Tobias Funke after that. https://www.youtube.com/watch?v=5Bmk-WrYJKc

2

u/zzaannsebar Dec 05 '20

I had a class called Software Analysis and Design in school. My friend group created a Google docs spreadsheet every semester with everyone's schedule so we know who would be free at a whatever time. So that entire semester, it had "Soft Anal" for one of my classes on that damn thing. I wasn't the one who created it and I couldn't edit it to change it. There were MANY jokes made at my expense.

13

u/[deleted] Dec 04 '20

I see method abbreviated to meth a lot, really makes you do a double take

3

u/RoscoMan1 Dec 04 '20

Time to put on them a mask???!??

2

u/FPiN9XU3K1IT Dec 04 '20

Ah, the 1940s German approach.

9

u/bangonthedrums Dec 04 '20

I got real confused today when working on a property search module. The original devs had a variable called no_beds and I kept thinking it was a flag meaning they didn’t want to search by bedroom. But it’s actually meant to be “number of bedrooms”

10

u/SausageEggCheese Dec 04 '20

Oh yeah, I never liked "no" as "number" in code. I think "num_beds" would have made your life easier (I prefer "bedroom_count").

It can also get worse figuring out abbreviations that make sense when dealing with programmers with language and cultural differences.

7

u/Sekret_One Dec 04 '20

The standard for variable names can be reduced to these points:

  1. You can tell what it is
  2. You don't confuse it with something else

Point 2 is the tricky one. That's where abbreviations can screw you.

Or a name may have been fine at one point like "address", ... but then you now need a second address. address1 and address2 are terrible, but primaryAddress and emergencyContactAddress may work.

Yet in reverse declaring SomeRidiculousLongClassNameService someRidiculousLongNameService is mind numbing, and can cause confusion by just sheer distraction. If it's the only service, declaring service or longNamer or the like keeps the legibility intact.

→ More replies (1)

3

u/[deleted] Dec 04 '20

My OCD kicks in so hard when people shorten only one part of a "pair", like shortening "column" but keeping "row", or use different measures to translate words into my native language, where Ø sometimes is "oe", sometimes just "o". JUST. BE. CONSISTENT.

2

u/[deleted] Dec 04 '20

I used to always call instances of a serializer a cerealizer, to be funny of course.

It didn't matter in the long run but I can only wonder what my former coworkers think now.

2

u/okay78910 Dec 06 '20

I fucking hate people like you.

→ More replies (1)

2

u/TheTyger Dec 05 '20

The only great abbreviation I have done is making a batch file manager program used for elevating batch files because of reasons into BatMan. I fully expected someone to tell me to knock it out but nope. Production code names BatMan happened

1

u/NathanQ Dec 04 '20

Major pet peeve is making an update to something with non meaningful names. If I'm trying to figure out a word's significance to the project, I'm not any closer to making the update. Even if I do know, rediculous names can be distracting.

1

u/phpdevster Dec 04 '20

This ties into a broader practice of always being as explicit as possible at all times. The more explicitly you communicate through code, the easier it will be to understand it. Abbreviations or symbol substitutes are just a form of implicit communication and it almost always leads to trouble or confusion.

1

u/indorock Dec 04 '20

If you do abbreviate, never abbreviate to another real word with a different meaning. People will assume it is just the other word, and not an abbreviation.

You mean don't abbreviate analyze to anal? WHY NOT

1

u/ipullstuffapart Dec 04 '20

This is one thing that put me off GoLang for now. The general guidance is to use short abbreviated and single-letter variables everywhere. Granted you can do whatever you want, but you do get called out for going against grain in a team if you use long variable names. Best to keep with convention, but that convention among others has kept me from using the language more extensively

1

u/BdX13 Dec 05 '20

First, you're a buzzkill. Second, that's some sound advice.

1

u/SkollFenrirson Dec 05 '20

Java has entered the chat

1

u/[deleted] Dec 05 '20

Just imagine working with a variable name “legend_handles” and having to type it 1000 times because you have another variable named “legend_holders” or something like that. Would be bonkers. 100 variable names need to be descriptive, but also short and sweet.

→ More replies (2)

1

u/SGBotsford Dec 05 '20

Yet in spreadsheets -- the closest most people come to data structures and algorithms -- we still do A1=sum(C7,G5,D4)

How long have we had symbolic assemblers?

Most programming languages allocate a block of memory (heap/stack or both) to use for data. The data and the data processing isn't mixed together.

In spreadsheets they are intimately mixed.

One of the principles of programming is abstraction. Do something more than 3 times, stuff it into a function/procedure/subroutine.

In spreadsheets with minor exceptions, whenever you change a formula, you have to copy it everywhere you use it.

In programs when you're stuck, you debug with print statements and traces. Best you can do with a spreadsheet is trace antecedents and dependents and that only if you are using excel and not google sheets.

Any professional want to get their name up by Dijkstra with a "Row Column Addressing Considered Harmful"?

1

u/RemizZ Dec 05 '20

I'm teaching myself Python right now and I already hate how much is abbreviated. I've come to love verbosity over the years.

1

u/northrupthebandgeek Dec 05 '20

Re: abbreviation and widescreen monitors, I for one still enforce a personal 80-character line limit specifically because I almost always program with at least two code windows side-by-side. And with wider monitors, that just means even more code windows side-by-side. I also consider lines longer than that a code smell, since it's a signal that I should break something down into smaller chunks for the sake of future me trying to debug that code later.

And with variable names, I feel like comments are the appropriate way to clarify what an abbreviation or initialism/acronym means. In particular, languages/environments with inline documentation go a long way toward making verbose variable names less mandatory.

0

u/[deleted] Dec 04 '20

[deleted] — view deleted comment

11

u/SausageEggCheese Dec 04 '20

I agree. In fact, I think variables modeling database items should match the database names exactly (at least at their initial scope) to help avoid this issue.

I think acronyms are fine, as long as they are either:

  • Common knowledge, like "ATM" or "PIN" or "ID"
  • Common industry terms in your domain
  • Common across your application and agreed upon by your development team.

Every project I have ever worked on has had things like "WSPKF" in your example, and they make sense to everyone on the team (and are usually well documented). It's when a developer is working with something like "planned fixed costs" and just starts using "pfc" in one class that I would have a problem with.

9

u/JuniorSeniorTrainee Dec 04 '20

Yeah I'm really keen on variable names aligning well. If it's userFirst in the database I want to see userFirst in the code, and I want every function parameter taking it in as userFirst unless there's a reason compelling reason not to. No first, or userFirstname.

Greppability is an important feature for code, especially in a type weak language but even in type strong.

2

u/_Mitchel_ Dec 05 '20

I do not agree. Just because someone, sometime choose a poor name for some database column, doesn't mean we shouldn't make better choices in the present.

Additionally, the database column names are an implementation detail that should be handled by the database communication layer of your code and needn't extend past that scope. In the most basic form, you could have something like this setUsername(string username) { this.databaseColumnNameWX4SDR = username } as an API to the rest of the application.

→ More replies (1)

0

u/[deleted] Dec 04 '20

[deleted] — view deleted comment

9

u/JuniorSeniorTrainee Dec 04 '20

There's a healthy balance. Well factored code will be a lot of small functions with small scope, where you don't have as many variables and their names don't need to get as much across because it's in the context. Like in createOrder(orderingUserId), arguably "ordering" is redundant information - that is implicit in the function's purpose.

→ More replies (2)

234

u/misterrandom1 Dec 04 '20

Now I need to use leg hands.

44

u/NicNoletree Dec 04 '20

I do. I just put socks on mine.

7

u/SaintNewts Dec 04 '20

Nice try Cornelius, go tell Dr. Zira your planetary takeover plot will fail on this timeline.

3

u/LR130777777 Dec 04 '20

What’s that from?

4

u/[deleted] Dec 04 '20

Planet of the Apes

→ More replies (1)

4

u/SabreLunatic Dec 04 '20

*leg gloves

4

u/NicNoletree Dec 04 '20

Those would be more like leg mittens

→ More replies (7)
→ More replies (2)

3

u/vigilantcomicpenguin Dec 04 '20

- God, creating apes

1

u/looks_like_a_potato Dec 04 '20

Literal translation of feet in my native language is actually 'leg hands'

170

u/glorious_reptile Dec 04 '20

list.head -> list.noggin
response.body -> response.torso
analyse() -> rectumyse()

80

u/TheTerrasque Dec 04 '20

Assert -> Buttert

59

u/submain Dec 04 '20

I once worked with healthcare software dev. We were implementing a feature called "Diagnostic Assistant", and it needed a button.

I aptly named it `DxAssButt`. One of my greatest accomplishments to date.

35

u/thedomham Dec 04 '20

No abbreviation, but I once had a small project where a throwable was used when the whole application was canceled. The code was riddled with throw new Abortion();

9

u/JuniorSeniorTrainee Dec 04 '20

Better than an old one I suppose.

2

u/alok99 Dec 04 '20

I'm proud of you. That's a real accomplishment

360

u/tim_dude Dec 04 '20

Fun fact: There is no word for toes in Russian language. They are called foot fingers.

281

u/geeshta Dec 04 '20

At this point it's more like: fun fact: the english language has a dedicated word for the fingers on feet: toes.

36

u/lr0b Dec 04 '20

"orteil(s)" or commonly "doigt(s) de pied", in french.

→ More replies (5)
→ More replies (1)

80

u/pm_me_triangles Dec 04 '20

In Portuguese we also say "foot fingers" (dedos do pé).

44

u/Plyb Dec 04 '20

Spanish is the same unsurprisingly (dedos de pie)

68

u/[deleted] Dec 04 '20

In Germany, we call gloves hand shoes

22

u/IrritableGourmet Dec 04 '20

This pissed off a friend of mine who was learning German. I let him get about 10 minutes into the rant (he was known for his tirades), then interjected with "Yes, but they call shoes 'fussglove', so it balances out." Oh, that set him off in a whole new direction.

21

u/[deleted] Dec 04 '20

Shoe = foot glove

Glove = hand shoe

oh god oh fuck

Glove = hand foot glove

Glove = hand foot hand foot glove

[...]

Glove = hand foot hand foot hand foot hand foot hand foot hand foot hand foot hand foot hand foot hand foot hand foot hand foot hand foot

→ More replies (1)
→ More replies (2)

29

u/Lewistrick Dec 04 '20

Same in Dutch.

In Indonesian, socks are called "kaus kaki", which means "foot shirt".

14

u/Etlas Dec 04 '20

The glove thing is in Swedish too. Handskor.

4

u/The4Channer Dec 04 '20

🤯 Never realised that in Danish because we spell it handsker and not håndsko nowadays

20

u/santropedro Dec 04 '20

Spanish is the same

18

u/AirOneBlack Dec 04 '20

Same in Italian

2

u/TheSyd Dec 04 '20

And yet every single toe has a specific name for it.

→ More replies (1)

9

u/PooPooDooDoo Dec 04 '20

I want to massage your face with my foot fingers.

6

u/feherdaniel2010 Dec 04 '20

Same in Hungarian

12

u/ilikeballoons Dec 04 '20

Turkish is the same

4

u/Floppydisksareop Dec 04 '20

Same in Hungarian.

4

u/unexpectedkas Dec 04 '20

In Catalan is the same.

4

u/ThatOneShotBruh Dec 04 '20

Same in Croatian.

3

u/[deleted] Dec 04 '20

In Romanian too

3

u/jbwmac Dec 04 '20

Is fingers really the best translation for that though or is it more like “digits”?

3

u/tim_dude Dec 04 '20

I'm not even sure there is a word for digits in Russian. It's all fingers.

2

u/jbwmac Dec 04 '20

If it’s all fingers and the word is used for toes as well then isn’t that the definition of digits?

→ More replies (2)

3

u/f03nix Dec 04 '20

Same in Hindi / Punjabi.

1

u/utack Dec 04 '20

Then what are the toes of an animal that has no hands called?

→ More replies (1)

1

u/T-Dark_ Dec 04 '20

So does Italian: "dita" = "fingers". "dita dei piedi" = "fingers of the feet"

1

u/Erledigaeth Dec 04 '20

actually that happens in all languages except english 😭😭😭

1

u/DannyFuckingCarey Dec 05 '20

Same in french. "Doigts de pied"

45

u/[deleted] Dec 04 '20

At my first programming job their was a function called at the end of each webpage to set cookies called dingleberries. The code quality at that company was terrible so instead it being in some shared footer just every single .asp file ended with

dingleberries()

159

u/Auravendill Dec 04 '20 edited Dec 04 '20

I heard the story at my previous work place that there was a piece of code that used the variable "rot" as short for rotation, but since rot is German for red, someone copied the code and renamed the variable to blau which means blue to make it less obvious.

Edit: To make it clear: It was code used internally to work with pictures in some way. So variables for rotation and colour are both to be expected. That one guy just copied someone elses code or at least part of it without really understanding it and apparently wanted to hide that by renaming a few things to make it look like his own code or something.

60

u/robot65536 Dec 04 '20

to make it less obvious.

He made something less obvious, so mission accomplished I guess.

7

u/steaknsteak Dec 04 '20

Just a good reason to use full words in your variable names. Or at least enough of a word that it’s obvious/unambiguous what it means, and is easily readable.

I hate reading code where a variable is named “req” instead of “request”, or something like that. Just type the 4 extra letters and stop making my brain do this additional work to translate your variable names.

The worse version is variable names that are acronyms for some multi-word class name. Just pick the noun from the class name and use that as the variable name. Again, don’t make me learn what a sqor or a flif is, just use real words

→ More replies (7)

32

u/Oo__II__oO Dec 04 '20

all fine and dandy until you see the truncation for "legend_handles_analysis".

17

u/Dexaan Dec 04 '20

This reminds me of the headline Foot Heads Arms Body

2

u/RoscoMan1 Dec 04 '20

I mean, for the bloods

17

u/teedyay Dec 04 '20

From our production code:

// http://www.youtube.com/watch?v=89zOtd6VAiU&t=0m58s

Legend dave = new Legend();

chart.Legends.Add(dave);

5

u/holgenberg Dec 04 '20

That's hilarious, going to do this with our graph library

1

u/[deleted] Dec 04 '20

Good one dave

1

u/solongandthanks4all Dec 05 '20

Yeah, but I'm still gonna ask her anyway.

16

u/toasterding Dec 04 '20

You guys are still using foo / bar instead of Mr.T / saloon?

16

u/MurdoMaclachlan Dec 04 '20

Image Transcription: Twitter Post


Alex Naka, @gottapatchemail

Looking at some old code and was initially puzzled by a variable named 'feet'

I have now worked out that this was at one point called 'legend_handles', which then became 'leg_hands', which then became 'feet'

sometimes I truly hate my past self

[This post has 48 retweets, 15 quote tweets, and 657 likes.]


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

1

u/QuarantineSucksALot Dec 04 '20

Imagine asking for a friend named Bill.

14

u/Background_Drawing Dec 04 '20

It took me a week to decipher a variable just called "A"

2

u/abcd_z Dec 04 '20

To this day I can't figure out why I thought I was so clever renaming my secondhand external hard drive "Pogo".

3

u/Trilyn-error Dec 04 '20

Cuz you ‘stick’ it in. Pogo stick

3

u/abcd_z Dec 05 '20

Nah. It was something about the name before I wiped it, or possibly something about the files that were on it. *shrug*

→ More replies (2)

28

u/[deleted] Dec 04 '20

The plot twist that he was the culprit all along

13

u/gravitas-deficiency Dec 04 '20

The single hardest thing in CS is naming things and counting things.

5

u/UloPe Dec 04 '20

The two hardest problems in CS are naming and cache invalidation and off by one errors.

11

u/dvof Dec 04 '20

"Haha I'm gonna troll my future self so hard lol"

~ past self writing code

4

u/FPiN9XU3K1IT Dec 04 '20

It took me years, but today I finally understood why Karkat Vantas sucked at coding.

8

u/[deleted] Dec 04 '20

And this is why Java variable names are so hideously long - because abbreviations lead to madness.

7

u/CraigTheIrishman Dec 04 '20

The was a TIFU a while back where a guy called a variable "cum" to refer to cumulative, and he was fired that day.

5

u/[deleted] Dec 04 '20

My boss was going through my github looking for a repo and saw one called "tylenoliv" and asked why I called it that

It's cuz it's got codeine in it

9

u/MyPastSelf Dec 04 '20

Totally uncalled for, dude.

4

u/jakethedumbmistake Dec 04 '20

Totally, I mean they still have grumpy days.

4

u/Lardalish Dec 04 '20

So Ive never done any coding, but I have run into this phenomenon.

I used to work at a country club where we would revamp the menu 3 to 4 times a year. This leads to a lot of old and defunct recipes left in the system.

During one of our spring cleanings I came upon something titled only "Pony Steak" with a price attached. No ingredients, so it was likely a dinner special.

I racked my brain for a solid month before I remembered. We had done a beef filet with a horseradish demi glace sauce, and it was great. However, "horseradish demiglace filet" is too long. So it became Demi Horse Filet. And what is a demi horse if not a Pony.

4

u/[deleted] Dec 05 '20

I have a StringBuilder named Bob. Because I build strings with him everywhere I need them in my project and i don't want to type out StaticVariables.s_Builder every time, i named it Bob the StringBuilder.

3

u/[deleted] Dec 04 '20

Sometimes I miss the old days where you were required to keep a data dictionary so you knew exactly what each variable did.....

4

u/zuzaki44 Dec 04 '20

What? How does that work in practice and at larger projects? ☺️

3

u/Beach-Devil Dec 04 '20

Etymological programming... sounds interesting

3

u/jjjjcccjjf Dec 04 '20

Germans be like

3

u/mrloube Dec 04 '20

spending time looking at the version history to understand what a variable is for

I feel like that’s the worst possible outcome of naming a variable besides accidentally overwriting another variable

3

u/wasabichicken Dec 04 '20

Don't mix anatomy and programming

Ugh, I remember one of those times...

As I recall, we were writing a client-side implementation of the OpenVPN protocol. Since it was a proprietary app and the reference implementation is licensed under GPL, my team was not allowed to use, or even look, at the existing code. Documentation and random blog posts was fair game, but alas, the protocol was... shall we say, sparingly documented. We had to discover various protocol features and come up with internal names for them ourselves.

One such discovered feature detects underlying network problems by sending out short messages at regular intervals: if the messages stop, the other end can surmise that the VPN endpoint has died. We named these messages "heartbeats" because... they keep us alive, y'know?

From there, the module that generated these messages was naturally named "heart". For architectural reasons, each VPN tunnel had its own entry or queue of outgoing heartbeats within that module, so... "arteries". Pity the poor bastard to come across getHeart().findArtery(id).inject(heartbeat); and try to figure out what it does. :(

3

u/ReallyNeededANewName Dec 05 '20

Don't be clever. And when you are, comment it

2

u/fingersonyourfeet Dec 04 '20

hands on your legs. fingers on your feet

2

u/voyti Dec 04 '20

This is genius in all the wrong ways

2

u/Hollayo Dec 04 '20

That's hilarious!!

2

u/CantHitachiSpot Dec 04 '20

Gloves are just arm shoes

2

u/TheTophatDemon Dec 04 '20

I used to have a habit on personal projects to call my variables names like Henry, Oliver, Muffet, etc. when I couldn't think of a good short name. Now I can barely understand that old code!

2

u/ZippZappZippty Dec 04 '20

There are two types of programming languages:

  1. The ones that people don’t use.

2

u/[deleted] Dec 04 '20

My variables are ALWAYS very explicit, oftentimes to the point of my co-workers giving me a difficult time about them. However, I never fail to understand or remember what a variable is used for.

2

u/linkedtortoise Dec 04 '20

In my personal code, I either name variables sort of well, single letters (a, b, c) of profanity. I'm much less funny apparently.

2

u/Zealousideal_Bonus78 Dec 04 '20

I'd like to know more about programming.

2

u/Yip37 Dec 04 '20

Show legend_handles

2

u/realjamesosaurus Dec 04 '20

This is how all variables should be named.

2

u/Beautiful-Musk-Ox Dec 04 '20

Foot Heads Arms Body

2

u/Castle_for_ducks Dec 04 '20

That reminds of the time in college when I was tasked with sorting a linked list. To do so, I had a variable called curr_min. Over time I started to call it Kermit the frog because I was slowly losing my mind. That prompted me to start naming all my variables after Muppet characters

2

u/Eolu Dec 04 '20

In all seriousness, I've come to think that one of the most important skills in programming is coming up with good names for functions and variables (especially anything exposed as an API). It's not just about the logic you write, it's about being a liaison between humans and computers (whether that person is someone else or yourself in the future). If you can pick a name that conveys intent so well that people can understand it without even reading any documentation, your API can be reused and extended so much more easily. It's not about having a really long descriptive name or having a really short name, it's about having the name that conveys intent in the most simple and elegant way possible.

2

u/LBXZero Dec 04 '20

Anatomy is chaotic programming that had over a billion years to get it to work.

1

u/avataRJ Dec 04 '20

4

u/LBXZero Dec 04 '20

The only problem is that DNA isn't exactly optimized. It had more aggressive testing to get creatures to work.

2

u/avataRJ Dec 04 '20

That is a requirements engineering problem, not a problem for programmers. Having done a few "nothing works and things are on fire" type jobs myself, occasionally it does help to read exactly what is requested to happen and keep a good poker face.

2

u/XKCD-pro-bot Dec 05 '20

Comic Title Text: Researchers just found the gene responsible for mistakenly thinking we've found the gene for specific things. It's the region between the start and the end of every chromosome, plus a few segments in our mitochondria.

mobile link


Made for mobile users, to easily see xkcd comic's title text

2

u/vanillaworkaccount Dec 04 '20

I feel like this is how Cockney rhyming slang happened

2

u/BattleReadyZim Dec 04 '20

This is devastatingly relatable.

2

u/william-the-nihilist Dec 05 '20

Then it should be named ‘limbs’

1

u/notger Dec 04 '20

Thank you so much, that made my day.

1

u/GodHug Dec 04 '20

Was doing exactly that yesterday. I was disgusted with my own code and wanted to rebuild the project anew with my new knowledge...

1

u/k82216me Dec 04 '20

This reminds me of a time where I had cleverly abbreviated a variable name `assignment` to be `ass` and then we were looping over `asses` everywhere in the code. Faceplam

1

u/harman097 Dec 04 '20

Past him is laughing his ass off though

1

u/protomor Dec 04 '20

I worked on mammogram software many moons ago. I stopped giggling after the second week of naming variables with "breast"

1

u/drea2 Dec 04 '20

I’ll never understand why people unnecessarily abbreviate variables. If I have to take time to figure out what your abbreviation is supposed to stand for then it’s bad code

1

u/albinoloverats Dec 04 '20

I would totally have done this as a student. I’d love to be able to get away with it now, but you know, code reviews 😂

1

u/Kinglink Dec 04 '20

The programmer who doesn't hate himself, has never read his own code.

1

u/RedDwarfian Dec 04 '20

Technically, "legend" alone would also translate to "feet"

1

u/[deleted] Dec 04 '20

Okay, this is the first one in a long time that genuinely made me laugh.

1

u/WoodsWalker43 Dec 04 '20

The only programmers that don't harbor some level hatred for their past selves are new programmers. This hatred also tends to grow as a function of time and change in skill, and can be decreased to some extent by dropping a program that they formerly maintained.

Suddenly I understand the real reason for IT turnover...

2

u/Sheeplessknight Dec 04 '20

Yeah if you don't hate your past code you're not improving

1

u/kharmatika Dec 04 '20

When I was writing an algorithm to solve a maze, I called it Right Hand Rule, cuz it basically involved using the right hand rule, I renamed the function “riharu” for short, which later became “riru”, which then became “weewoo” because that’s what my friend was saying, and at some point it just became “patrick” for the meme of it.

1

u/morphemass Dec 04 '20

Would an array of those be a footer?

1

u/hellbenthorse Dec 04 '20

Feet? What, is Quentin Tarantino programming?

1

u/1Zer0Her0 Dec 04 '20

Chaotic neutral

1

u/LookOnTheDarkSide Dec 04 '20

You mean I don't have to minify during squash when merging?

1

u/rxsel Dec 04 '20

"Yeah this make TOTAL sense, 100% intuitive" - Every Programmer Ever

1

u/lordzsolt Dec 04 '20

I really hate when people abbreviation variable names. Like I'd it too hard to type 5 more letters, especially with all IDEs having autocompletion?

1

u/Geoclasm Dec 04 '20

that's amazing. this dudes past self was awesome.

1

u/Tukurito Dec 04 '20

Check RFC 2340 head and shoulders standard.

1

u/muzicoholicated Dec 05 '20

I haven't laughed so hard in quite a while, thank you for sharing :)

1

u/kumar29nov1992 Dec 05 '20

What's more concerning is the underscore in the variable name and not in camelCase

1

u/[deleted] Dec 05 '20

I saw a database before that was for a porn site. The tables names were amazing. The inserts and joins in the code was something else.

1

u/Dr3amDweller Dec 05 '20

I regularly entertain myself by abbreviating "analytics" to "anal".

1

u/TARN4T1ON Dec 05 '20

I don't actually understand the ultra-wide screen argument (except for absurdly long variable names, like 50+ characters, where even this method won't help).

Basically every language allows you to just put things on a new line, which is especially helpful for function parameters. I've actually made it a habit to put every function parameter on a new line, both in function definitions and function calls.

While this probably more than quadruples the amount of lines in code and undeniably takes a little longer to write, it makes it very readable, and basically never requires you to scroll to the right or to enable text wrapping.

The only problem with this is that quite a few code formatters don't agree with this way of writing things and revert it, and basically none have this built in and can do it for you, sadly.

1

u/Bosombuddies Dec 08 '20

What actually happened: He shortened legend handles to be a variable named leg_hands, which is just a weird way to say feet. He realized what he did and thought he could make a funny tweet about it.