henfredemars ,

I worked with a developer who insisted on using the shortest names possible. God I hated debugging his code.

I’m talking variable names like AAxynj. Everything looking like matrix math.

ray ,

At a previous job I had to work with an old database where all the tables and columns had 6-character names

wfh ,
@wfh@lemm.ee avatar

Same. Old DB2 base from the 80's that was migrated to Oracle in the 90's then to Postgres in the 2010's.

And the people there know all the column names by heart 😅

xmunk ,

I vomit whenever I have to read one letter alias SQL. And then.... I dealias it.

nogooduser ,

I don’t understand why people think that it’s acceptable.

As developers, we’ve had it drummed into us from day one that variable names are important and shouldn’t be one or two letters.

Yet developers deliberately alias an easy to read table name such as “customer” into “c” because that’s the first letter of the table. I’m sure that it’s more work to do that with auto completion meaning that you don’t even need to type out “customer”.

xmunk ,

Especially when you also have company and county tables. It forces people to look up what the c is aliased to before beginning to comprehend what you're doing.

redcalcium ,

Ah, must've been a fortran developer. I swear they have this ability to make the shortest yet the least memorable variable names. E.g. was the variable called APFLWS or APFLWD? Impossible to remember without going back and forth to recheck the definition. Autocomplete won't help you because both variables exist.

mkwt ,

And you can write more than six characters, but only the first six are recognized. So APFLWSAC and APFLWSAF are really the same variable.

And without namespaces, company policy reserves the first two characters for module prefix and Hungarian notation.

henfredemars ,

He did write some Fortran in his past! What made you think it was Fortran influence?

geogle ,
@geogle@lemmy.world avatar

72 characters per line/card.

Templa ,
@Templa@beehaw.org avatar

I'd say because fortran is often used for calculations such as numerical analysis where you have x, y and z for example.

I have written fortran code in the past and it was mainly for that.

redcalcium ,

Your first few programming languages usually influence you the most for the rest of your career.

HaywardT ,

And the rest of you are COBOL programmers.

dan ,
@dan@upvote.au avatar

shortest names possible

This film from 1975 is still relevant today: https://www.youtube.com/watch?v=7hdJQkn8rtA

NegativeLookBehind ,
@NegativeLookBehind@lemmy.world avatar

You should really be naming all your variables by generating 64 character (minimum) random strings.

rufus ,

Make it 63 (31?) to align with what C99 can distinguish.

Also: I really like unicode in identifiers. So if at all possible don't just have a random string of letters and numbers, make sure to include greek letters and all the funny emojis. (I just forgot which languages and compilers etc allow that.)

NegativeLookBehind ,
@NegativeLookBehind@lemmy.world avatar

Wingdings as well

aBundleOfFerrets ,

Wingdings is a font and has no effect on the actual code. Only people who set their IDE font to wingdings will see wingdings

NegativeLookBehind ,
@NegativeLookBehind@lemmy.world avatar

Remove all fonts from the devs computers except for Wingdings and Webdings.

BodilessGaze ,

For extra fun, you can name your variables using solely Unicode invisible characters (e.g. non-breaking space) so they're impossible to visually distinguish

LostXOR ,

Who needs private variables when you can generate cryptographically secure variable names? Much better security.

owenfromcanada ,
@owenfromcanada@lemmy.world avatar

Nah, I name all my variables after my homies.

int dave = 0;

rufus ,

does dave know he's a zero?

codfishjoe ,

His best friends index starts at 0

owenfromcanada ,
@owenfromcanada@lemmy.world avatar

In zero-based indexing, zero is #1.

imPastaSyndrome ,

Dave was number one!

XTL ,

But they had to be enterprise, so he became a number one factory.

smeg ,

Ah, the XCOM approach. Now you look after those variables and get sad when you have to delete them.

perviouslyiner ,

Just be careful naming your function "stdout()" or things could get weird...

mkwt ,

Or Fortran variables that collide with Fortran built-in functions.

Keep in mind that array subscript and function call are both () in Fortran.

MentalEdge ,
@MentalEdge@sopuli.xyz avatar

FullSentenceExplainingExactlyWhatItDoes(GiveThisVariable, SoItCanWork)

kautau ,
Kolanaki ,
@Kolanaki@yiffit.net avatar

Was just talking about gaming genre names being kinda lame (roguelike? Souls-like? Where's the originality?!) and this just furthers my point as programming and video games are intrinsically linked.

outer_spec ,
@outer_spec@lemmy.blahaj.zone avatar

floats, doubles, etc are decimallikes. object-oriented programming languages are c++likes. a string that is just the word “false” is a boollike. any language easier to learn than c++ is a pythonlike. any language harder to learn than c++ is a asmlike. don’t like it? then you’re a naglike. you don’t want to be known as a naglike, do you?

owenfromcanada ,
@owenfromcanada@lemmy.world avatar

Javascript is all about them boollikes (or as we sometimes call them, booleish).

PoolloverNathan ,

Haskell, my favorite pythonlike!

FrostyCaveman ,

Single character variable names are my pet peeve. I even name iterator variables a real word instead of “i” now.. (although writing the OG low level for loops is kinda rare for me now)

Naming things “x”.. shudder. Well, the entire world is getting to see how that idea transpires hahah

Mikelius ,
@Mikelius@lemmy.ml avatar

I hate short variable names in general too, but am okay with them for iterators where i and j represent only indices, and when x/y/z represent coordinates (like a for loop going over x coordinates). In most cases I actually prefer this since it keeps me from having to think about whether I'm looking at an integer iterator or object/dictionary iterator loop, as long as the loop remains short. When it gets to be ridiculous in size, even i and j are annoying. Any other short names are a no go for me though. And my god, the abbreviations... Those are the worst.

FrostyCaveman ,

That’s very reasonable, I can get behind that. (my stance is a partly irrational overreaction and I’m totally aware of it lol)

Abbreviations are definitely annoying. My least favourite thing to do with them is “Hungarian notation”. It’s like.. in a statically typed context it’s useless, and in a dynamically typed context it’s like.. kind of a sign you need to refactor

Cethin ,

Hungarian notation makes sense in a dynamically typed usage (which I despise, but this essentially makes them notationally typed at least) or where you're editor/IDE is so simple it can't give you more information, which I can't see ever being the case in the modern day.

Redkey ,

Most people use the term "Hungarian Notation" to mean only adding an indicator of type to a variable or function name. While this is one of the ways in which it has been used (and actually made sense in certain old environments, although those days are long, long behind us now), it's not the only way that it can be used.

We can use the same concept (prepending or appending an indicator from a standard selection) to denote other, more useful categories that the environment won't keep straight for us, or won't warn us about in easy-to-understand ways. In my own projects I usually append a single letter to the ends of my variable names to indicate scope, which helps me stay more modular, and also allows me to choose sensible variable names without fear of clashing with something else I've forgotten about.

Cethin ,

X, y, and z should only be used when working with things with dimensions larger than 1. Indexing into a 2D array, x and y are great uses. I'm also totally fine with i and j for indexer/iterator when appropriate, but I hate when people try to make short variable names for no good reason. We have auto-complete just about everywhere now. Make the names descriptive. There's literally no reason not to.

Hazzia ,

We have auto-complete just about everywhere now

vim

sparkle ,
@sparkle@lemm.ee avatar

Everywhere CIVILIZED*

Bobbettes ,

Vim can have autocomplete.

PoolloverNathan ,

Press ^X^N, I dare you.

nicky7 ,

Same, except for list comprehension in python, I prefer sinlge character var names there.

JoYo ,
@JoYo@lemmy.ml avatar

^- triggered

steventhedev ,

Older C compilers would truncate a variable name if it was too long, so VeryLongGlobalConstantInsideALibraryInSeconds might accidentally collide with VeryLongGlobalConstantInsideALibraryInMinutes.

Legend says that they used to do it after a single letter with Dennis declaring "26 variables ought to be enough for anyone".

olutukko ,

I had this problem in my job as a drafter. I was wondering why the hell Tekla would complain about the same object name already being in use despite everything having its own name. took me way too long to realize there wad some stupidly max name length and the program did nothing to alarm the user about trying to put too long name. it just cut the overflow away.

Malix ,
@Malix@sopuli.xyz avatar

installing operating system: 15 minutes, give or take.

give a name to the computer: 45 minutes

SturgiesYrFase ,

I've got that shit on lockdown man.
I name all my devices "Fuck0ff" followed by a 3 letter descriptor of what it is. E.g. - my windows install is Fuck0ffDTW for Desktop Windows, my Garuda install is Fuck0ffDTG for Desktop Garuda(it's a flavour of Arch, btw)

OfficerBribe ,

What if you would have 2 devices of same type with same OS or just with OS that starts with same letter? Will you use numbers, if yes, how much leading zeroes if any you will use? If you don't use numbers, will you add a room name? But what if there are 2 devices with same OS in the same room?

SturgiesYrFase ,

Luckily I'm not responsible for naming my wife's devices, otherwise the whole scheme would be up shit creak. As it stands I have a dual-boot desktop, a daily laptop, a surface pro4, and an old laptop running Ubuntu server for various self hosted stuff. I've managed to just use 3 letters, I assume as I amass more tech I'll need to start adding numbers, if I have to label for rooms I'll have more than a data hording problem.

DarkSurferZA ,

Gotten even easier after X became a registered trademark. Now the only choice we have left is i. Or ii if you need more variables

Cethin ,

"j" is what you're supposed to use if you need another index variable after using "i".

Bougie_Birdie ,
@Bougie_Birdie@lemmy.blahaj.zone avatar

Okay, say you've got four inner loops (a crime on its own, I know), do you use i, j, k, l or i, j, k, ii?

cbazero ,

lIIl, IIIl, lIlI and IllI

DarkSurferZA ,

This is the way

xlash123 ,
@xlash123@sh.itjust.works avatar

To the person who decided I and l should look the same in fonts, I wish you a pleasant eternity in hell.

lars ,

Imagine if your username were iars. Awful.

lars ,

An important professor constantly and frustratingly said

we can call this variable whatever we want, so we’ll call it Fred

Made me panic and irate and focus on the wrong part of the problem. Every. Single. Time.

RandomVideos ,

Since a lot of the english words i know i learned from minecraft, in a farming simulator i named tilled soil"hoed"

I had multiple variables like int isHoed

velvetThunder ,

There's some hoed in this house
If you see 'em, point 'em out

ZILtoid1991 ,

Then you realize your code is undebuggable because half the functions and variables have single-letter names or called foo, bar, baz, etc.

Hazzia ,

Especially when you reuse each of those names for all the scopes you have

ObsidianNebula ,

I have a somewhat related real world story. I had a client that was convinced that tons of people were going to decompile their application and sell their own version of the program, so they insisted that they needed their code obfuscated to protect company secrets and make it harder to reverse engineer. I tried explaining to them that obfuscation wasn't that big of a deterrent to someone attempting to steal code through reverse engineering and that it would likely cause some issues with debugging, but they were certain they needed it. Sure enough, they then had a real user run into an issue and were surprised to find that their custom logging system was close to useless because the application was outputting random obfuscated letters instead of function and variable names. We did have mapping files, but it took a lot of time to map each log message to make it readable enough to try to understand the user's issue.

Johanno ,

This is why you obfuscate after you code. Just obfuscate the release build. And logging may at that point be thrown out of the window anyway

ObsidianNebula ,

It was obfuscated only in the release build. The issue is that they have a system to send certain logs to an API so they can refer to them if a user has an issue that needs further investigation. Unfortunately, their target audience is not very tech literate and have a hard time explaining how they got into a situation where they experienced a bug, so the remote logging was a way to allow us to try to retrace the user's steps. Some of the logs that get sent to the API have JSON values converted from class data, will refer directly to class names, etc, and those logs had the obfuscated names.

Johanno ,

Well then you are fucked.

The question is if nobody else has access to the logs, then obfuscation is stupid

AnarchistArtificer ,

I was learning python as a wee scientist in training, and my variables were beyond dreadful. I tried naming a list "list" and the interpreter told me I couldn't, so I opted for "listy". When I needed to name a new list but listy was taken, I'd often resort to "listyy".

Scientists who work with computers without having much (if any) targeted training on how to code can write the most horrendous programs.

gandalf_der_12te ,
@gandalf_der_12te@discuss.tchncs.de avatar

How to write spaghetti code:

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • kbinchat
  • All magazines