TIP: Click on subject to list as thread! ANSI
echo: artware
to: All
from: Meikel Brandmeyer
date: 2003-03-28 16:46:00
subject: coding style

Hi,

during the work on my last patch I noticed the complete chaos of naming
function and variables. I noticed at least three different styles:
 - foobar()
 - foo_bar()
 - FooBar()
Maybe we should work out a style, which is used in new code and to which
old code can be migrated step by step. Right now the code looks like a
mess.

Suggestion:
 - indent is 4 spaces (no tabs)
 - global variables are named with the 'FooBar'-scheme
 - global functions are named with the 'foo_bar'-scheme with some prefix
 - local (static) functions are named with the 'foo_bar'-scheme
 - only one way of commenting. I prefer '/**/', but '//' is also possible (C99)
 - never use strcpy, etc. Always use strncpy, etc. Maybe one should add
wrapper for those. (something like strlcpy, which ensures, that a '\0' is
present at the end)

I'd like to suggest also to include some parts of style(9) of FreeBSD. Most
of that resembles my opinion on good coding style.

Something, what looks strange on the first sight, but is much more readable than

char *foo;
unsigned int bla;
int bar, baz;

is 

unsigned int    bla;
char           *foo;
int             bar, baz;

These are just some thoughts. No need to start a djihad.

Ciao
Meikel

--- timEd/FreeBSD 1.11.a5
* Origin: -=[ Ceres/BSD (Kaiserslautern, Germany) ]=- (2:244/1165)
SEEN-BY: 206/0 633/267 270
@PATH: 244/1165 1200 2432/200 774/605 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.