[gameprogrammer] Re: A Note on C Programming Style
- From: Wes Wannemacher <techgeek@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Fri, 6 May 2005 13:37:43 -0400
On 5/6/05, Robbert de Groot <zekaric@xxxxxxxx> wrote:
>=20
> One line per definition? That's a lot of typing. I have one
> function in my work code which has about a screen page or two of
> variables (yes, large functions do exist and no, breakthing this baby
> down isn't really in the cards.)
>=20
> Plus I generally define variables as such, also one per line but not
> as anal.
>=20
> char *p =3D NULL,
> letter =3D 'a',
> *string =3D "str",
> cat,
> dog,
> **dolt;
> int flag =3D FALSE,
> a,
> b,
> *ilist;
> ...
>=20
> I basically comes down to preference and coding style. No one way is
> better than the other. If you've found a way that works for you,
> perfect, but it may not be for everyone.
>=20
I feel like weighing back in here and agreeing with Robbert. I can go
either way with whether or not to declare each variable on a seperate
line. I would say that I spend just as much time doing maintenance as
I do writing from scratch. And, in the previous organization, each
change had to go through a full code review, and my experience was
that it was easier and quicker to make as few actual changes as
possible. Because of internal policy *all* changes had to be reviewed,
even changes to whitespace and other trivial edits. As time would go
on, what started as a simple module/procedure/function would balloon
into a large mess of spaghetti code because I wasn't the only one that
believed in only changing what was necessary. The business would
rarely approve re-writes, so maintenance coding usually meant wading
through messes and finding what needs fixed. I'm not sure where I'm
going with this rambling, but I will say that over time, I got very
used to seeing declarations like:
char *cpVal1, caVal2[MAX], cVal3;
int iVal1, **ippVal2, iaVal3[16], *ifpFunc();
I think one of the best rules though is something that one of the
Architects told me (who was a *very* senior developer and one of my
mentors in life). He told me to just do what I think is going to look
right. There are tons of style rules and convention, but in reality,
if I make it look good in it's context, chances are that other
developers will be able to understand it as well... To add to that, at
some point I spent some time learning to use CTAGS which is a great
tool.
-Wes
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Re: A Note on C Programming Style
- From: Robbert de Groot
Other related posts:
- » [gameprogrammer] A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- [gameprogrammer] Re: A Note on C Programming Style
- From: Robbert de Groot