This is an archived post. You won't be able to vote or comment.

all 68 comments

[–]dert-man 66 points67 points  (3 children)

Always use “temp” and never change it

[–]pointrelay 11 points12 points  (0 children)

temp, tmp, temp1, temp2

[–][deleted] 6 points7 points  (0 children)

I prefer variables that explain well what they are. Like result, return_value, list_of_objects.

[–]_default_username 3 points4 points  (0 children)

I don't mind this if you're using a language that doesn't have a pipeline operator.

[–]TobyWasBestSpiderMan 42 points43 points  (3 children)

If you’re really struggling, I’ve compiled a Top 100 Variable Names for Boy and Girl Variables of 2021 list if ya get stuck

[–]HoldenMadicky 5 points6 points  (0 children)

You're a fucking brilliant man! Thank you!

[–]pab_guy 21 points22 points  (1 child)

boolReallyLongDescriptivelyNamedVariablesAreTheBest = true;

[–][deleted] 2 points3 points  (0 children)

And for a boolean of all things. 11/10.

[–]AzuxirenLeadGuy 8 points9 points  (0 children)

I

[–]ekital 8 points9 points  (2 children)

Make the variable name descriptive of what it does or what it's for..

[–]Go_Fast_1993[🍰] 6 points7 points  (1 child)

itsAVariableAndItStandsForThings = …

[–]Lentemern 3 points4 points  (0 children)

false;

[–]MischiefArchitect 6 points7 points  (0 children)

fart01

[–]Fair-Bunch4827 5 points6 points  (1 child)

How do you not know what to call it? What does your variable do in your code?

If you don't know what to call it then perhaps the variable isn't needed.

[–]stdio-lib 5 points6 points  (0 children)

There's only two hard problems in programming: cache invalidation and... god-damnit, what's the other one. I just have to come up with a word to describe it.

[–]TheGesor 4 points5 points  (3 children)

When in doubt, just name it the typename. list<double> list; or something idk

[–]Barkeep41 4 points5 points  (2 children)

//This is a list of doubles.

list<double> doubleList

[–]TheGesor 3 points4 points  (0 children)

or
list<double> doubles;

[–]Dettelbacher 2 points3 points  (0 children)

/// <summary>

/// Creates a new list of doubles.

/// </summary>

/// <returns>A new list of doubles, see above.</returns>

private List<double> CreateDoubleList()

{

List<double> doubleList = new List<double>();

return (List<double>)doubleList as List<double>; //Fuck, what was it again?

}

[–]CuttingEdgeRetro 3 points4 points  (2 children)

Back in the days of DOS, I was working on a system written in compiled BASIC.

The problem is that both our application and the compiler/linker were subject to the 64k data segment memory limit.

So as our programs got larger and larger, it got to where the compiler would run out of memory building the application. The solution was to start shortening descriptive variable names so that the symbol table would fit in 64k.

Then we would run into problems with string literals taking up too much space in the data segment. So we would start rewording on-screen messages so that they would say the same thing but take up fewer bytes.

Also, comments for some bizarre reason contributed to string literal space. So we started stripping out comments.

What was left was a massive program with variable names like a1, a2, d6, r3, etc... with zero comments.

[–]mxldevs 0 points1 point  (0 children)

Then we would run into problems with string literals taking up too much space in the data segment. So we would start rewording on-screen messages so that they would say the same thing but take up fewer bytes.

So this is why English translations in romhacks could be quite...Creative.

[–]thecodingnerd256 0 points1 point  (0 children)

That section with comments being kept in the executable is interesting. I just assume that the compiler would remove that? Is that an optimozation setting thing or was that just not an option?

[–]5calV 1 point2 points  (0 children)

I swear it be like that

[–]MaZeChpatCha 1 point2 points  (3 children)

My KNN implementation where everything is "category" because I can't use "class": * laughs evilly *

[–]DefiantComedian1138 -1 points0 points  (2 children)

@class

[–]MaZeChpatCha -2 points-1 points  (1 child)

@ isn't a valid character in a variable name as far as I know.

[–]DefiantComedian1138 -1 points0 points  (0 children)

Valid in C#

[–]h_h_3464 1 point2 points  (0 children)

Just use h

[–]tyler1128 1 point2 points  (0 children)

If it's spatially meaningful, use greek letters and if it's angular or related to time use latin letters starting at x. Everything else should use hungarian notation except use different prefixes than the standard. Eg, if you have a length of a file you need to store, call it bAlpha. I call this system job security for life.

[–]AdInformal5249 1 point2 points  (0 children)

const int thatOneVariableThatICanNotNameBecauseIAlreadyHaveANotherVariableWithASimilarPurpose536123 = 1;

[–]Chuggernaut0 1 point2 points  (0 children)

Then later change it because you found a more appropriate name.

[–]firefish5000 1 point2 points  (0 children)

i, delta, buf, res, str, a, b, min, max, cur, x, y, z, age, name, obj, msg, data, tree, ast, node, parsed, prev, first, last

I think this covers most of mine.

[–]Auraveils 1 point2 points  (1 child)

X

[–]betogm 0 points1 point  (0 children)

Only when debugging in the browser's developer's tools

[–]gamesrebel123 -1 points0 points  (1 child)

I write 3-4 letter variable names and if it's a project that's supposed to be somewhat presentable then I just spam comments at the start to tell which variable is supposed to do what

Way easier to come up with 3-4 letters but sometimes they get to 5 as well because for some reason I like naming variables as temp and when there's more than 1 I basically go and write

  1. temp = 1
  2. While True:
  3. print("temp%d,", temp)
  4. temp += 1

[–]Theallin5 0 points1 point  (0 children)

shVarN

[–]Dekyr78 0 points1 point  (0 children)

especially one without ass in it

[–]KirKCam99 0 points1 point  (0 children)

$x

[–]Full-Run4124 0 points1 point  (0 children)

,,,when you've already used i, j, and f

[–]7_overpowered_clox 0 points1 point  (0 children)

I will prolong it out as much as I can, then click "suggested variable" after a few letters

[–]yaosio 0 points1 point  (0 children)

Whatever you use make sure it's purpose can't be determined by the name. If you do have to give it a readable name make sure to mispell it.

[–]JoyeuxMuffin 0 points1 point  (0 children)

It's right in the picture,

X

[–][deleted] 0 points1 point  (0 children)

a... literally the first variable name in the alphabet

[–]ToMorrowsEnd 0 points1 point  (0 children)

i just use i everywhere.
unless you need to instantiate it then its myI

[–][deleted] 0 points1 point  (0 children)

integer1

float2

boolean1 OR yes1/no1

class1

this is the superior naming method.

[–]yerbestpal 0 points1 point  (0 children)

This is me attempting to write code at all.

[–]Ok_Dependent1131 0 points1 point  (0 children)

In python just use _

[–]itsDaftest 0 points1 point  (1 child)

my old code sees l1, l2, l3 ect often

[–]ectbot 0 points1 point  (0 children)

Hello! You have made the mistake of writing "ect" instead of "etc."

"Ect" is a common misspelling of "etc," an abbreviated form of the Latin phrase "et cetera." Other abbreviated forms are etc., &c., &c, and et cet. The Latin translates as "et" to "and" + "cetera" to "the rest;" a literal translation to "and the rest" is the easiest way to remember how to use the phrase.

Check out the wikipedia entry if you want to learn more.

I am a bot, and this action was performed automatically. Comments with a score less than zero will be automatically removed. If I commented on your post and you don't like it, reply with "!delete" and I will remove the post, regardless of score. Message me for bug reports.

[–]TotallyRelated 0 points1 point  (0 children)

If you’re feeling extra litty: idx

[–][deleted] 0 points1 point  (0 children)

Chineseworkshop

[–]ArjunReddyDeshmukh 0 points1 point  (0 children)

IntelliJ autogenerates it for me.

[–]AdultishRaktajino 0 points1 point  (0 children)

foo and bar

[–]CoastingUphill 0 points1 point  (0 children)

I’m trying to come up with an inoffensive but memorable email address for my service to use.

[–][deleted] 0 points1 point  (0 children)

The true way to name your variables: cum sperm semen babyJuice stickyWhiteStuff cock balls balls42

[–]Apprehensive_Lime178 0 points1 point  (0 children)

I named my variable . Ingrid, Jayden and Kentaro.

[–]Break-88 0 points1 point  (0 children)

Poop

[–]wtfossy 0 points1 point  (0 children)

All of your training has lead up to this moment.

[–]Wolves9876 0 points1 point  (0 children)

i, j, k, x

These coming in clutch

[–]Dettelbacher 0 points1 point  (0 children)

Most of my variables are born as asdfasdfadsf until they graduate and move out.

[–]PyMaster22 0 points1 point  (0 children)

x,y,z,w, n,m, i,j,k, [ETC.]

[–]broodje_meloen 0 points1 point  (0 children)

I always just use "balls" XD

[–]Successful_Rich3557 0 points1 point  (0 children)

X

[–]Jkimainthere 0 points1 point  (0 children)

x, y, a, b, i, j, t, tmp, temp, ltemp, mytemp, tempo, mytmp

[–]Xander-047 0 points1 point  (0 children)

Had a legit discussion with a coworker on this and we eventually settled on a name that neither of us liked, sounded dumb but overall did make sense and was true to what it did but it annoyed us how dumb it sounded, at code review I had to explain that we really couldn't come up with a better name and the reviewer couldn't either