Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coding standards



 On Thu, 05 Jun 2008 08:04:04 -0400 
Stephen Adler <[hidden email]> wrote: 

> What are common coding standards (or web pages discussing the issue?) 
> 
> I'm working with a group of coders and I need to impose some kind of 
> sensible coding standards... 

Lots of different coding standards. Much depends on the language used. 
C, C++, and Java have similar forms, then there if FORTRAN and COBOL 
that have yet other standards, then there are scripts like shell 
scripts, Perl, Python. 

With C and C++ one of the biggest issues in standards are the placement 
of the curly braces. I have always used the K&amp;R style proposed by Brian 
Kernighan: 
if (expression) { 
        code indented by 1 indent (emacs like to use 4 spaces). 
} 

Note that the open curly appears on the same line as the 'if', and the 
closing curly is in the same column as the 'i' in 'if' 

Another style is: 
if (expression) 
{ 
        indented code 
} 

And yet another is: 
if (expression) 
        { 
        code 
        } 

In K&amp;R, Brian discusses his reasoning for the style. 

There is another standard on variables.   
Variable names are usually mixed case with the first word being lower 
case: 
index or annualPayment. 

manifest constants and cpp macros should be all upper case. 
#define FOO 

Class and type names are capitalized such as 
class BostonLinux { 

Here is a decent web site: 
http://geosoft.no/development/cppstyle.html

The bottom line is to paraphrase George Orwell, 
Break any of these rules sooner than code anything outright barbarous.. 

-- 
-- 
Jerry Feldman <[hidden email]> 
Boston Linux and Unix 
PGP key id: 537C5846 
PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB  CA3B 4607 4319 537C 5846 
_______________________________________________ 
Discuss mailing list 
[hidden email] 
http://lists.blu.org/mailman/listinfo/discuss
 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org