308
submitted 2 years ago by qaz@lemmy.world to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] Gentoo1337@sh.itjust.works 46 points 2 years ago

I remember one GitHub project that implemented some algorithm (I think it was Dijkstra's) but only used 4 or 5 single letter variables and just kept reusing them.

[-] lorty@lemmy.ml 8 points 2 years ago

When you are used to math equations, it's easy to slip into that habit.

[-] Pxtl@lemmy.ca 7 points 2 years ago

Single letter variables, yes. Reusing them? No.

[-] MooseBoys@lemmy.world 4 points 2 years ago

Only if they are well-known in the language you’re using or domain you’re writing for. x and y are fine for coordinates. i and j are fine for loop indices. But abbreviating things unnecessarily is bad IMO. s = GetSession() is too terse, for example.

[-] Pxtl@lemmy.ca 3 points 2 years ago

No, I mean single-letter vars are standard in physics and math, but reusing vars is not acceptable. Obviously they're not good practice except in the scenarios you describe, but mathies gonna math.

load more comments (2 replies)
load more comments (6 replies)
this post was submitted on 15 Oct 2023
308 points (95.3% liked)

Programmer Humor

37159 readers
335 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS