this post was submitted on 12 Sep 2024
289 points (96.2% liked)

Programmer Humor

19623 readers
2 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

var Turtle1 var Turtle2 var Is_Turtle

you are viewing a single comment's thread
view the rest of the comments
[–] parpol@programming.dev 23 points 2 months ago* (last edited 2 months ago) (3 children)

Yeah, a name should describe what it is or does, so if you have two turtles, and let's say turtle1 wants to shit on turtle2's lawn, you could name them shittingTurtle and victimTurtle. If the name alone tells you what its purpose is, that saves a lot of time for people looking at your code.

Is_Turtle is not a bad variable name because it tells you it is a Boolean with "is" and that the Boolean tells you whether something is a turtle or not.

Also, depending on the language, I suggest either camelCase or snake_case naming of variables. PascalCase is usually for defining classes or in case of C#, methods.

[–] Repelle@lemmy.world 13 points 2 months ago (1 children)

SHOUTING_SNAKE_CASE aka SCREAMING_SNAKE_CASE is the best case for all use cases, because it gives you a chance to use its wonderful names.

[–] Klear@lemmy.world 13 points 2 months ago (1 children)
[–] MajorHavoc@programming.dev 8 points 2 months ago* (last edited 2 months ago)

Thanks. I hate it.

I consider myself a collector of programming anti-patterns, but I didn't have this one yet.

[–] OttoVonNoob@lemmy.ca 3 points 2 months ago* (last edited 2 months ago)

I'm gonna be honest I just used Turtle ad an example:X .. when it's actually like a GoldCost, GoldC and GoldH. Where GoldR is a reset var and GoldC is the paid value. GoldCost is self explanatory but I really spagettied it up XD...

[–] MajorHavoc@programming.dev 2 points 2 months ago

Thank you for this. This is awesome.

shittingTurtle and victimTurtle are going into one of my professional slide decks as soon as I think I can get away with it.