this post was submitted on 09 Sep 2023
2 points (100.0% liked)
Programmer Humor
35334 readers
1 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Does anyone have any good advice on variable naming? Here's some of my rules I try to live by:
utils_FooBarisnotin bool names._g_VARIABLENAMEcalc_ImportantValueThatWillDecideTheUsersViewis better thancalc_SumYearsif the variable is more important than the others.Edit: I realize I was speaking about function-naming with the prefix stuff.
For variables, I still use prefixes, but for variable type. Even if you define the variables as types, it's still incredibly useful. For instance,
a string is
s_MyName,enumerable is
e_MyType,A number is int or double or whatever
i_MyAgeord_MyWeightThis might be obvious for custom objects, but I'd still do it like this
p_Personorper_Person.Seriously it does make a huge difference