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
1 day ago
Snudget
:rust::py::asm:
  • 1 — Naming things
  • 3 — Race conditions
  • 4 — Packet duplication
  • 2 — Off-by-one errors
  • 4 — Packet duplication
1 day ago
Mayion

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

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

1 day ago
RiceBroad4552
:s:

Do you have scientific prove of this claim?

I bet the issues only move elsewhere, as the problem is always the same.

The correct solution would be to have two functions: offsetBy (currently wrongly called "index" by most people) and indexOf (which is missing in more or less all programming languages).

1 day ago
Emergency_3808

I've never had issue with point 1. I can still deal with off by one errors. Race conditions makes me want to kms.

1 day ago
dan-lugg
:kt::cs::g::j::p:

Wait, point 2 as they're labeled, or 2 as they're ordered?

Why do want make they you to kys?

1 day ago
the_horse_gamer

I like to say "four" and then: * 1 - naming things * 3 - race conditions * 2 - off by one errors * 4 - cache invalidation * 2 - off by one errors

20 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

1 day ago
private_final_static

In your past self defense, thats hilarious.

Im sure debugging through that wasnt.

1 day ago
SupernovaGamezYT
:m:

I have done similar things lol

1 day ago
ovr9000storks

No, no, I think you were onto something there

1 day ago
HomsarWasRight
:bash::ts::sw:

git blame:

YOU, MOTHERFUCKER!

1 day ago
Unupgradable
:cs::ts:

You have no one to blame but yourself

1 day ago
whitakr

Kinda want to start calling my feet leg hands though

1 day ago
JuicyAnalAbscess

In many languages toes are called "foot fingers"/ "fingers of the feet" or something similar.

14 hours ago
Emergency_3808

Documentation has left the chat

1 day ago
joe________________

What does caraccy mean

1 day ago
ThisUserIsAFailure

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

1 day 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

1 day ago
SphericalGoldfish
:cp:

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

1 day ago
B_is_for_reddit OP
:py: i have no idea what im doing

thats the joke

1 day ago
RiceBroad4552
:s:

It's in fact "CAR acc y".

It obviously stands for Critical-Arithmetic-Register-Accumulator-Yield.

1 day ago
HeavyCaffeinate
:lua:

player1ObjectCarAccuracy or player1ObjectCarAcceleratorY

1 day ago
apnorton

stopShorteningVariableNamesISTG

Oi. Stop shortening your variable names!

1 day ago
RiceBroad4552
:s:

I bet it's part of the joke.

1 day 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

1 day 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;

```

1 day ago
apnorton

People get allergic to it after they see some kind of Java nonsense like:

IReducedWidgetFactoryFactoryHandle<RobotWidget> westCoastRobotWidgetReducerFactoryFactoryHandler = new ReducedWidgetFactoryFactoryHandle<>();
westCoastRobotWidgetReducerFactoryFactoryHandler.generateFactory().generateWidget(COLORS.RED_AND_BLUE, urlForRoboticsData.asSafeUrl());
1 day ago
PutHisGlassesOn

But like, that’s helpful.

18 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 
1 day ago
Nesuma

Which resource constricted environments keep variable names during runtime?

1 day 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?

1 day ago
Swamptor

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

1 day ago
DerfetteJoel
:cs:

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

1 day ago
RiceBroad4552
:s:

First of all, there are more or less no directly interpreted languages. Show me one.

Not even Python does that.

It's all at least byte-code.

Besides that, I want to see prove that long symbol names could cause a directly interpreted program to run slower than it anyway runs. This claim is imho ridiculous.

1 day ago
sheriffjt

That isn't what I claimed. One example is Salesforce Apex, which governs how many characters can be used throughout your entire codebase. 

15 hours ago
RiceBroad4552
:s:

Clearly written out text is difficult to read and understand? Especially in comparison to some asldkfjalsdkjf bullshit?

WHAT?!

Some people simply shouldn't be allowed by law to touch any code…

1 day ago
sheriffjt

Just because a name is long doesn't mean it's clearly written out. Long names can also be ambiguous, they aren't a panacea to fix a lack of documentation.    

Also, just because you disagree with someone doesn't mean you should be a dick.

15 hours ago
Clen23

Long names are difficult to read, short names are impossible to read.

18 hours ago
sheriffjt

Balance is the key.  

doGet() is too short and meaningless.  

getSettings() is succinct.

getMyApplicationSettingsJSONForUserConfigurationSection() is too long and unnecessarily verbose.

I feel like people unwilling to seek balance are the "all my code is self documenting" crowd

15 hours ago
PhantomTissue

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

1 day ago
BSModder
:cp::cs::lua::upvote:

If the variable name gets too long it's harder to read than just short variable. I'd rather use i,j,k for index than indexForTableA, indexForRowB, indexForColumnC.

1 day ago
MegaMoah
:cs:

What about tableIndex, rowIndex, colIndex instead?

1 day ago
UltraGaren

I'd rather have long name variables than confusing variables all day.

Who cares if it is named RequestNewUnitMenuButtonPrefab, it least I know exactly what it does

1 day ago
Spice_and_Fox

I work as an SAP developer. Variable names are no longer restricted but database tables, class names, structure names, etc. very much still are. They fixed this with s4 hana systems, but a lot of companies still use r3 systems so it will take a while until everybody makes the switch. Database tables are the worst offender. They can be at most 16 characters long. Our company requires us to start with the company shorthand (3 characters) and end with the customer number in case of customer specific objects (5 characters). It can be very hard to find a fitting name on that case. This somehow is reflected in the variables as well, variables who are related to a database table will have the name, etc.

21 hours ago
rover_G
:c::rust::ts::py::r::spring:

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

1 day ago
RiceBroad4552
:s:

Which is irrelevant as you don't write and read type names but symbol names!

Most of the time the types are anyway inferred, so you never see them.

1 day ago
rover_G
:c::rust::ts::py::r::spring:

I take it you’re not familiar with the history of Hungarian notation?

1 day ago
private_final_static

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

1 day ago
RiceBroad4552
:s:

People who don't understand that code is read many times more often than written, and that it's therefore most important to optimized for reading, never for writing, shouldn't be allowed by law to touch any code, imho.

This brain dead abbreviation bullshit needs to have an end!

There is absolutely no reason to use abbreviation since autocomplete exists. Especially as autocomplete has has fuzzy matching.

1 day ago
ganjlord

Verbose names don't always add clarity and can result in overly verbose code which takes longer to read by virtue of being longer and more dense.

An example from a recent project is "btnInfo". I could have used "acceptButtonInformation", which is more specific and avoids abbreviation, but both are just as clear in context IMO.

1 hour ago
Pastalala
:c:

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

1 day ago
InfectedShadow

Please rename to stopShorteningVariableNamesISwearToGod

1 day ago
Big__Meme
:ru:

Lazy fucks using "i" instead of its full name "eye"

1 day ago
huttyblue

Because scrolling horizontally to see the entire line is annoying.

1 day ago
DaniilBSD

Skill.. i mean Screen Issue

Also use word-wrap

1 day 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

1 day ago
RiceBroad4552
:s:

Yeah sure, that's a great excuse to write cryptic shit!

(Besides it isn't, as other pointed already out…)

1 day 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.

1 day 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. 

1 day ago
DigitalJedi850
:cs:

I feel like ScopeName.VariableName should usually be enough.

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

1 day ago
Buttons840

"A good variable name is its own documentation."

Which is why all my variable names are thousands of characters long and each one fully documents itself.

Except for x, if something is self-evident I just name it x.

1 day 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 :<

1 day 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.

1 day ago
RiceBroad4552
:s:

Do you code in notepad?

All text editors worth their salt have fuzzy matching. Since decades…

1 day ago
generally_unsuitable

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

struct * obj

Just . . . dude. No.

1 day ago
braindigitalis
:cp::c::asm::p::unreal::msl:

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

1 day ago
SignificantLet5701
:cp::c::j::rust:

car account??? Y-axis ig

1 day ago
nobody0163
:c::cp::cs::py::ts::asm:

Car accuracy

21 hours ago
The_Real_Slim_Lemon
:cs:

*junior developers. In high school my variables had one letter names - now my vars have a short story in them.

6 hours ago
Irbis7
:c::cp::py::rust:

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

1 day ago
RiceBroad4552
:s:

My condolences.

Thanks God we're over this since decades, and now there exists no reason to write cryptic code. Besides being a stupid dick, of course.

1 day 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.

1 day ago
RiceBroad4552
:s:

OMG!

I hope I never have to see that garbage.

Using comments instead of properly naming things is the most ridiculous shit I've heard in some while. BRR!

1 day ago
Nerketur

Nono, you misunderstand.

I always try to properly name things. Comments are for when the logic doesn't make sense at first glance.

I'm an avid supporter of "code should be self-documenting"

1 day ago
70Shadow07

But no, comments bad!!!!! In my todo app all variable names are descriptive and 2 words most!

1 day ago
Nerketur

I can't tell if that is sarcasm or not.

In case you are serious...

That's not descriptive to me, and comments are great. More people should use them.

Code that you write that is just for you? Doesn't matter if it's readable for anyone but you. Future-you may have a bone to pick with you, though.

Code that you write that others have to be able to read? The goal is make it readable at a glance. If it's not obvious what a piece of code does without having to think about it, it needs a comment. If you can't tell what a variable is used for at a glance within 2 seconds, it needs a more descriptive and/or shorter name.

I don't need a sentence to describe a variable.

18 hours ago
70Shadow07

Bro are you five ofc its sarcasm I cant believe one can't pick up on "!!!!!!!"

Anyone with a drop of thought in their mind knows that you can't express everything in "self documenting code" like brother in christ that is what documentation is for lol.

13 hours ago
Nerketur

The people I have to work with on a day to day basis would use "!!!!!!" genuinely.

13 hours ago
70Shadow07

Holy shit, thats insane lmao

9 minutes ago