|
I have used and will continue to use "temp" for a temporary variable that lives for one or two lines of code.
|
|
|
|
|
I always use something meaningful, even if it is a throwaway variable. I work hard to make my code readable and think of whether the name will help or hinder me six months from now. I have worked in way too much legacy code that took forever to figure out and understand maintenance is where the bulk of programming time gets spent. (much to my dismay!)
|
|
|
|
|
I learned from this series of posts to utilize "str" for strings. I never liked using "string" since it conflicts w/ std::string. I always use "using namespace std;"
I favor descriptive names however I would rewrite doubleCalculateOffsetForWaveFunction(intScaleFactorForWaveFunction,floatWaveFunctionSeedValue)
as
Offset_forWaveFunction(scale_factor, seed_value)
I don't believe in Hungarian notation as it is merely another source of error and of course the return value is already documented. "Calculate" is redundant since we know that's what functions do. I find it helpful to distinguish prepositions in the name. "ForWaveFunction" is not needed since the variable is in context. If this method was of a class WaveFunction then all that would be needed would be Offset(scale_factor, seed_value). My local variables are always lower case. Capitals I reserve for global or public objects.
I am fascinated by naming notation conventions. I like the notation to say something about the method and variable e.g. to distinguish public methods from private e.g. camel for public and snake for private though I am conflicted as I like snake as it is easy on the eyes with no capital letters shouting at me though I am currently utilizing all capitals for statics and terminate all lambdas with "_LAMBDA". I am eager to learn of other's techniques and preferences. - Cheerio
modified 23-Apr-21 11:16am.
|
|
|
|
|
Thanks for that it is very interesting.
Quote: doubleCalculateOffsetForWaveFunction(intScaleFactorForWaveFunction,floatWaveFunctionSeedValue)
Gee.
I can read your rewrite easily.
The original is like a the name for a Welsh town and the only person who could read that would be the OriginalGriff.
I have never used ALLCAPS for anything. No reason, just never even thought about it. Therefore no titleCASE case either.
I usually use camelCase now but used to use CamelCase. I sometimes but rarely use snake_case or a cross between it and one of the camel styles just for some emphasis.
For Public variables I always distinguish these with a g prefix. Like gWaveVal. The g indicates Global.
It is fascinating to hear what other peoples preferences are and also the reasons for their preference.
Thx
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
I once came across a function whose purpose was to send a message to the Sales And Marketing application. The developer had amusingly but appropriately named the function TelegramSAM. Unfortunately, they had then got a little carried away:
The author was listed as M. Bolan
The variables were named "jungle", "faced", "jake", "make", "no" and "mistake".
|
|
|
|
|
This made me laugh.
What a great name for the function.
Almost the perfect name but in retro case.
It may fly completely over the head of younger developers though.
I like the idea of having a theme though.
However easy to get carried away.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
Hands down the 3 hardest problems in programming:
-naming stuff
-off-by-1-errors
For throwaways, I usually pick my repertoire of Result (for holding something that'll get returned) and Scrap (generic temporary).
For stuff like responses from dialog boxes, I either take my old-and-tried Scrap, or give it some meaningful name like "SerialNo" when the user is prompted for a serial.
|
|
|
|
|
Never heard of Scrap before so this is a new one for me.
I like naming stuff though and find this the easiest part.
Mind you have regretted some of my names.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
Some people have called my code idiosyncratic.
i , j , k for loop indices with scope inside the for loop.
rc for any numerical function return code with a small scope.
val for many kinds of value, as a formal argument name.
that for the argument of a copy constructor.
My input variables tend to have real names.
I mostly store results in variables instead of using the rvalue result because it's typical that I have to test them more than once.
|
|
|
|
|
Short and sweet is OK.
I detest super long naming. I am Lazy.
I will usually use i, j and k for loops but I also use n.
Preference order is i, n, j and then k.
I have no idea of why n became the second choice.
But it sort of just makes sense, as we can use it and it is a number.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
For decades I too used i,j,k for loops, but over the last years I increasingly switched to more telling names, so I wouldn't need to constantly check and doublecheck whether or not I'm referencing the right index within a triply nested loop. It's much easier to accidentally use "i" and "j" incorrectly than "row" and "column"!
This change of mind was caused mainly by having to read so many nested loop codes and constantly stumbling over the problem that code containing such nested loops would often do this not just once, but several times, but not always use the same index variables for the same index
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I'll admit having switched more recently to row and col instead of i and j for some loops. I have to say that a triply nested loop is very uncommon in my experience, except for performance testing.
Gotos are a thing I don't understand. I haven't written a goto in 20 years. I just don't need them. Gotos are for people who don't understand C++ well enough.
|
|
|
|
|
Does Nicola Sturgeon[^] like like a younger version of Angela Merkel[^].
Maybe it's a Lady-Prime-Minister thing . . . or a cloning experiment gone wrong?
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I think she looks more like a grown-up Jimmy Krankie.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: like a grown-up Jimmy Krankie But not as pretty. 
|
|
|
|
|
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
I just found myself Ctrl-Tabbing between the two images.
What on earth am I doing?!?!?
I need or possibly ![Beer | [beer]](https://codeproject.freetls.fastly.net/script/Forums/Images/beer.gif)
|
|
|
|
|
It is just the haircut.
She is a lawyer not a scientist.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
grralph1 wrote: She is a lawyer not a scientist. She's neither: she's a politician.
grralph1 wrote: It is just the haircut. Along with the facial features - yeah I see what you mean.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Quote: She's neither: she's a politician.
Well she is now.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
W∴ Balboos, GHB wrote: or a cloning experiment gone wrong?
Or maybe it's politics that do that to you.
|
|
|
|
|
Data format inserted in charged particle (11)
// TODO: Insert something here Top ten reasons why I'm lazy
1.
|
|
|
|
|
Information ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
Too easy. You're up tomorrow.
// TODO: Insert something here Top ten reasons why I'm lazy
1.
|
|
|
|
|
Way too easy especially the charged particle
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|