ProgrammerHumor

stopShorteningVariableNamesISTG

stopShorteningVariableNamesISTG
https://i.redd.it/kr5jbb01h2cf1.gif
Reddit

Discussion

dan-lugg
:kt::cs::g::j::p:

There are two bothersome problems in software development:

  • 1 — Naming things
  • 3 — Race conditions
  • 2 — Off-by-one errors
5 hours ago
Snudget
:rust::py::asm:
  • 1 — Naming things
  • 3 — Race conditions
  • 4 — Packet duplication
  • 2 — Off-by-one errors
  • 4 — Packet duplication
3 hours ago
Mayion

2 hours ago
B_is_for_reddit OP
:py: i have no idea what im doing
  • 0- naming things
  • 2- forgetting syntax
  • 1- maths
5 hours ago
HeavyCaffeinate
:lua:

The off-by-one errors increase significantly when you program in Lua

3 hours ago
Unupgradable
:cs::ts:

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

5 hours ago
SupernovaGamezYT
:m:

I have done similar things lol

4 hours ago
private_final_static

In your past self defense, thats hilarious.

Im sure debugging through that wasnt.

4 hours ago
ovr9000storks

No, no, I think you were onto something there

4 hours ago
whitakr

Kinda want to start calling my feet leg hands though

3 hours ago
HomsarWasRight
:bash::ts::sw:

git blame:

YOU, MOTHERFUCKER!

2 hours ago
Unupgradable
:cs::ts:

You have no one to blame but yourself

11 minutes ago
joe________________

What does caraccy mean

5 hours ago
B_is_for_reddit OP
:py: i have no idea what im doing

thats the joke

5 hours ago
ThisUserIsAFailure

(full name) player 1 object character (or just car if theyre driving a car) acceleration Y-axis is my best guess

4 hours ago
fumui001

Could be p1ObjCarAccY, at least the word can be separated

But why cant it be p1CarAcclY (acceleration became accl to avoid confusion with "accuracy")

Actually, why am I even taking this too seriously lol

4 hours ago
SphericalGoldfish
:cp:

No no, it IS accuracy. It’s for implementing how much the camera shakes vertically when attacking

4 hours ago
HeavyCaffeinate
:lua:

player1ObjectCarAccuracy or player1ObjectCarAcceleratorY

3 hours ago
CanThisBeMyNameMaybe

I never understood why devs are so allergic to long variable names? I rather know what your variable is for than it being short

4 hours ago
whitakr

Since Objective-C was one of my first programming languages, I started off being used to ridiculously long variable and function names. For example, from Apple’s official code (before they transitioned to mainly Swift):

``` - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath;

```

3 hours ago
sheriffjt
  1. Overly long variable names are difficult to read and make the code harder to understand.  
  2. Extra characters means a larger size, which may be important in some environments 
3 hours ago
Nesuma

Which resource constricted environments keep variable names during runtime?

3 hours ago
relativeSkeptic

Yeah don't a lot of languages optimize things like that away during execution?

Like a 15+ character variable name gets converted to a single letter after the compiler converts the code to machine code no?

3 hours ago
Swamptor

Uhm, axchually machine code doesn't have variable names 🤓

2 hours ago
DerfetteJoel
:cs:

Yes, but not every language is compiled into machine code. Scripting languages are usually interpreted at runtime dynamically.

2 hours ago
PhantomTissue

Use a minifying tool. Keep the long variable names and let the tool change “myLongAssVariableNameThatDescribesASpecificUse” to “a”

3 minutes ago
rover_G
:c::rust::ts::py::r::spring:

Some languages have more descriptive (and strong) types than others.

4 hours ago
apnorton

stopShorteningVariableNamesISTG

Oi. Stop shortening your variable names!

4 hours ago
private_final_static

Regular PR: - 100 comments about formatting - everyone missed how Im mining bitcoin

4 hours ago
Pastalala
:c:

Dawg, context based autocomplete is something even base VIM does! 😭

3 hours ago
huttyblue

Because scrolling horizontally to see the entire line is annoying.

4 hours ago
B_is_for_reddit OP
:py: i have no idea what im doing

use a smaller font size

edit: and break bracketed code into multiple lines for clairty anyway

4 hours ago
DaniilBSD

Skill.. i mean Screen Issue

Also use word-wrap

1 hour ago
ThisUserIsAFailure

the thing is the autofill is dumb and i need to type out the first word and then part of the second word to get it to get the right one, and typing out a single word is hard :<

4 hours ago
GalaxyMaster06
:j:

There are however IDEs (anything from Jetbrains) which support camel case autocompletion.

As a Java developer, this IntelliJ feature is extremely useful.

4 hours ago
DigitalJedi850
:cs:

If I need more than like… two words in a variable name, something’s wrong. Usually about when I decide I need to break out into another function, honestly.

5 hours ago
AdvancedSandwiches

If I need less than three words in a variable name, that's when I go looking for other important clarifications I can add to the name. 

4 hours ago
DigitalJedi850
:cs:

I feel like ScopeName.VariableName should usually be enough.

GetReplies(RootComment) for example feels… sufficient. To each their own though.

4 hours ago
generally_unsuitable

I have a senior who likes to call the struct pointer passed to the function

struct * obj

Just . . . dude. No.

3 hours ago
braindigitalis
:cp::c::asm::p::unreal::msl:

... sure... p1obj  == player one object  but wtf is a caraccy 

2 hours ago
Nerketur

OP must be an Objective-C fan.

Famously long variable names.

As for me? Nah. I like short but obvious.

A single letter for loop variables if it's solely for the loop, otherwise naming what it is.

If I have to move my eyes or my head to see the whole name, it's way too long.

My goal isn't description, it's efficiency. As readable as possible, while being as short as possible. Functions should be a few lines at most. Single-line functions should be in-lined, instead, unless it's to create a single place to change something. Reuse of code to do a lot of similar tasks is the goal.

Then, any time it's too complex to understand but space-savings are significant means it's a place for a comment.

4 minutes ago
Irbis7
:c::cp::py::rust:

I learned to program on ZX Spectrum. All variables were one character long.

3 hours ago