Page 1 of 1

Poll: Programming style

Posted: Fri Mar 21, 2003 9:54 am
by Whatever5k
So what do you prefer? Something like

Code: Select all

CreateProcess();
or

Code: Select all

create_process();
I'm using the underscore version...what about you?

Re:Poll: Programming style

Posted: Fri Mar 21, 2003 10:03 am
by Curufir
Actually I switch between the two to differentiate between functions and variables, with constants in uppercase underscored.

So you get things like (C examples, in ASM I use the same scheme):
SomeFunction()

Some_Variable

SOME_CONSTANT

The only thing that doesn't follow that scheme are loop counters, which are always lowercase and a single letter.

I'm not sure it really matters which scheme you choose to use, just so long as you use it consistently throughout your code. I'd like to think mine makes my code more legible, but it's difficult to quantify something like legibility when you're the one writing the code.

Re:Poll: Programming style

Posted: Fri Mar 21, 2003 10:13 am
by AGI1122
Deleted the other topic.

And as I said in the other topic, I prefer lowercase/underscore. ;D

Re:Poll: Programming style

Posted: Fri Mar 21, 2003 12:03 pm
by stonedzealot
I just use lowercase, no underscores or anything, I like to be able to get through the entire function pushing shift only every once in a while

Re:Poll: Programming style

Posted: Fri Mar 21, 2003 12:31 pm
by Tim
I use both. PrefixVerbNoun() for public functions, prefix_lower_case for public module variables, and lower_case for local variables and struct field names.

Re:Poll: Programming style

Posted: Sat Mar 22, 2003 8:13 am
by ark
I prefer the UpperCase format for function names. For variable names, I usually use initial lower case and then upper case for the first letter of all other words, as in thisIsAVariableName. Except I also generally use Hungarian notation, so the actual name of the variable is in UpperCase format, but the type abbreviation is all lowercase, as in:

unsigned long ulSomeVariable;

I only use underscores for constants, because I type them in all uppercase (like THIS_IS_A_CONSTANT), and for scope specification (as in g_ for a global variable).

Re:Poll: Programming style

Posted: Sat Mar 22, 2003 9:16 pm
by sonneveld
I used to use lowercase with underscores in the NAGI code but later on, I've started adopting a more capitalised approach.

UpperCaseName for structs, classes..
lowerThenUpper for variables and instantiations of structs or classes.
then BLAH_DE_BLAH still for macros

- Nick

Re:Poll: Programming style

Posted: Wed Mar 26, 2003 10:35 am
by Pype.Clicker
prefixGlobalFunction(), _localFunction()

prefixStructureName.oneword, fctparameter, localvar

can we still qualify such an everchanging policy as a "writing style" ... of just the lacking of one ?

Re:Poll: Programming style

Posted: Sat Mar 29, 2003 2:24 pm
by distantvoices
in my opinion it is more important to give the functions and variables MEANINGFUL names to keep the need to comments minimal.

I also think it is important to give the code some structure and to avoid possibly GENIOUS pointer constructs which no pig can understand a week later: writing easy readable code with clear layout is more important than any geniousness which makes the whole stuff looking scanny and weird.

stay safe folks