Poll: Programming style

Programming, for all ages and all languages.
Post Reply
Whatever5k

Poll: Programming style

Post 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?
Curufir

Re:Poll: Programming style

Post 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.
AGI1122

Re:Poll: Programming style

Post by AGI1122 »

Deleted the other topic.

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

Re:Poll: Programming style

Post 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
Tim

Re:Poll: Programming style

Post 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.
ark

Re:Poll: Programming style

Post 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).
sonneveld

Re:Poll: Programming style

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Poll: Programming style

Post 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 ?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Poll: Programming style

Post 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
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Post Reply