46 points

I remember one GitHub project that implemented some algorithm (I think it was Dijkstra’s) but only used 4 or 5 single letter variables and just kept reusing them.

permalink
report
reply
38 points

When I was in college, I had a guy that I was working on a project with that did this constantly. At one point I looked at one of his files and the variables were named a, b, c, aa, ab, ac, ba, bb, etc. That when I was like, bro, you gotta stop doing this.

permalink
report
parent
reply
41 points

“Inside you there are two wolves…” or something:

Option 1: Sit down with them and go line by line through it. Make him identify each variable’s purpose and then immediately find and replace to rename every instance with a more descriptive name.

Option 2: Small script to shuffle the variable names in his code around after each of his commits.

permalink
report
parent
reply
4 points

The guy thinks in Excel.

permalink
report
parent
reply
8 points

When you are used to math equations, it’s easy to slip into that habit.

permalink
report
parent
reply
7 points

Single letter variables, yes. Reusing them? No.

permalink
report
parent
reply
4 points

Only if they are well-known in the language you’re using or domain you’re writing for. x and y are fine for coordinates. i and j are fine for loop indices. But abbreviating things unnecessarily is bad IMO. s = GetSession() is too terse, for example.

permalink
report
parent
reply
-1 points
*
Removed by mod
permalink
report
parent
reply
6 points
*

Maybe they had a background in low-level assembly code? If you’re writing assembly that’s kinda sorta how you’d handle registers.

permalink
report
parent
reply
30 points

“result” is fine. That is the variable you will end up returning that you have to fill with stuff first.

“data” on the other hand…

permalink
report
reply
5 points

I came here to say this.

Declare result in the first line of the function and return result is the last line. In C++, this is a big hint to the compiler that you want return value optimization to kick in.

permalink
report
parent
reply
25 points

As a person who victimizes coworkers like this, I apologize. Thank you for pointing it out, and I will stop doing it.

permalink
report
reply
12 points

Be proud that it’s a step up from var x

Be scared that your coworkers are planning how to best apply the baseball bat to your knees anyway

permalink
report
parent
reply
2 points

Even using absolute best prackies, developers are gonna find a bunch of stuff to complain about.

permalink
report
parent
reply
21 points

Well obviously it’s the result of some algorithm that will happen.

permalink
report
reply
8 points

function algorithm(input)

permalink
report
parent
reply
1 point

Will name every of my functions like this now, thank you for pointing out that incredible meaningful name

permalink
report
parent
reply
19 points

I’ve had instances where I worked with an API so badly designed in a dynamic language that I had no idea what I might receive.

This, when I get something back that’s not what I expected, I just logged the type because I really don’t know what it is. It’s the result. Whatever that means.

permalink
report
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 3.6K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments