What is your variable name of shame?

What is the worst name you have ever written in code for a variable, function or class? Bonus, for those who use Git or version control. What’s the worst commit message?

The worst commit message I ever came across was “Mystery commit”.

1 Like

“temp”: the emperor of bad variable names

5 Likes

I think the only place this is excusable is in a swap

temp = x
x = y
y = temp

Here the scope is so tight it’s clear what it does.

1 Like

item1, item2, item3
and so on.

// This is a comment

1 Like

I started out programming the Commodore Vic 20, with a whopping 5K of ram (4.5K available for use) and every character of the BASIC program counted.

So…all one-letter variable names. And no spaces! (not required in that dialect, though in case of ambiguity, it might parse it wrong…) As much as possible on one line (each new line was more bytes). Every trick in the book to save a byte here and there, so the code looked like…perl.

And for the opposite…I once had a coworker who used almost-complete-sentences for variable names (“to make it clear”).

4 Likes

In the project I’m working on right now, I have different speed variables to move different components in a simulation. For a while, I had them named speed, speed2, speed3. That got confusing real fast. I’m also guilty of using Manager and Controller in my class names.

2 Likes

This could be a result of my earliest programming influences writing BASIC programs on my Commodore 64, but to this day, my first thought for a variable name of looping indexes is ‘i’. :slight_smile: Of course, I don’t use single variable names (in most cases) because after a little more thought, there is usually a better name, but I do miss the short variable names sometimes.

Actually, that is the one area I thought could be covered in this lecture. How long is too long when choosing the right name for your variable? With smart code editors today, it’s easy to completely refactor variable names without much pain, but I find it difficult to choose a concise name sometimes, especially when you code in a language that prefers underscores between variable words.

1 Like

Probably not that big of a deal, but naming variables after the first letter of their data type/class when being passed into a function, such as Foo(string str) or Bar(Dog d)

Worst Git commit was definitely leaving a blank space

2 Likes

Initial Kermit the frog.

I doubt that is my worst, it’s the one I remember.

2 Likes

I’m of the opinion that i isn’t that bad. Because it is very well understood by most programmers to be the index of a loop. But sometimes there is a better name and we should use it. But not just to expand it to index as I think that’s redundant with most experienced programmers. It all comes back to code = communication. Can the person on the other end understand you easily?

1 Like

I once wrote a “word processor” on a 5k (+8k expansion cartridge) Vic 20. It would let you edit exactly one page at a time. All of my freshman year term papers were written using it.
You really appreciate just how different programming is today and how much more we can do with our computers when your first one was sold to you by William Shatner.

1 Like

I tend to agree, i in a for loop, or alternatively x, y, and z, are in their own right self explanatory. Even then, I sometimes see problems in nested loops where somebody will use i, j, and sometimes even k, but then increment i instead of j in the nested loop.

Here’s my git commit of shame, from a real project of mine:
image

1 Like

int a = 2;
int b = a + 3;
int x = b - a + 1;
// This is a comment
int v = x * b - b + a * 2

variableName
variableNameB or variableName2

un = User.Name;

2 Likes

Worst git commit:
Clean Up
More Clean Up
Clean Up
Reformat
Tidy Code

(yes, all of those in the same project and not even that long between them)

2 Likes

I had a short project a while ago that I was just using to test an idea and get to grips with some programming concepts. I really just wanted to go as fast as possible so I didn’t give any thought to variable names.
In the moment, rather than the classic throwaway x, y, z, I thought it would be funny to call my variables “poo”, “bruh”, and “ladsladslads”. Can’t even remember what the project was anymore.

I’ve also got one git repository where half the commits are “minor changes” (aka I can’t remember what I changed). That one will be staying private.

3 Likes

:joy:

1 Like

Ah yeah, the VolksComputer. I started on the C64 myself.

If I remember correctly, it was fff. Not counting programing on Commodore 64, those were always one or two letters.

My worst variable name has to be “Manager”, when I was totally obsessed with the Singleton Pattern I had managers inside managers, once I created a project with 15 or so static classes, you can imagine the size of that spaghetti.

I often use Star Wars memes when I messed up the Git, I think one was “This aren’t the refactors you are looking for, move along, move along!”.

3 Likes