I'm looking at this previous test, and it says "Uses proper variable and function naming conventions". My problem is, what is considered proper? Are they referring to standard, camelCase? CamelCase? I guess I just don't get what proper is.
Three answers:
Tyler Camp
2012-12-26 01:42:33 UTC
Think about it in terms of what you would do if you were told this by an employer. Just name it as you deem appropriate - lower/UpperCamelCase, hungarian notation, underscore separations, it depends on the situation. If you're just writing an application, it's up to you. If you're working with pre-existing code, then go with what they used or a subtle variation of it.
Proper is however you want to interpret it. So long as you don't have variables named "****", (Yahoo apparently censors this, but it was the F-bomb) as was in the Doom 3 source code, or calling a function "swaggajohn," as I found in a previous game I worked in, you're writing code using properly-formed naming conventions.
Shady
2012-12-26 07:41:14 UTC
I would assume proper naming conventions is takes two things in consideration.
1. Making relevant variable names instead of just naming it a, x, y ,z etc...
2. First letter of every variable should ALWAYS be lowercased unless it is a global variable. So like you said... camelCase = function variable and CamelCase = global variable.
3. (extra) Functions follow the same rules as variables. I wrote a program that is able to check for the first 10,000 prime, fibonacci numbers. I named my functions checkPrime and checkFibonacci. Their names in themselves are descriptive as what the function actually does. Also the lowercase letter thing applys as well.
Good luck!
2012-12-26 08:00:05 UTC
You mean your problem is you weren't paying attention when this subject was explained.
Hungarian notation is the most well known convention, what YOU are required to do is between you and your professor. We can't help. For one thing, it depends on the flavor of c++ you are compiling. For another it is definitely organization/team dependent.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Search results for 'What is the proper naming convention in C++?' (Questions and Answers)