Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Industry coding standards
filburt1
Join Date: Feb 2002
Posts: 6,144

Maryland, US
by filburt1 filburt1 is offline 27 Apr 2003

Half of these are from NASA's Java style guide that I use at work(http://aaa.gsfc.nasa.gov/Files/JavaFinal.doc).

1. Use whitespace liberally for readability:
Wrong:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Right:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

2. Braces on newlines:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Right:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

(this might not look important but in big files it greatly helps)

3. Don't exceed 80 chars per line (for code printing and reading on low-res and effectively-low-res environments). No example because it'll break the layout here, but if a line exceeds 80 chars, break it up a bit before 80, and then continue it on the next line while indenting one tab (NASA suggests two tabs but it can make the code very messy).

4. Use a 4-space (not a tab character) indent.
Wrong (right from vB2...):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Right:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

5. NEVER use deprecated methods of coding. Examples:
1. $HTTP_POST_VARS
2. $somearray[somenonconstant]
3. mysql_db_query()

Fixed:
1. $_POST
2. $somearray['somenonconstant'] (a very common problem that you need to lose!)
3. mysql_query()


There are more and I don't mean to sound pushy, but every single thing I've said in this post is considered the professional industry standard and if you program for a profession then you'd be expected to follow these.
Views: 3113
Reply With Quote
Comments
  #2  
Old 27 Apr 2003, 20:32
grog6's Avatar
grog6 grog6 is offline
 
Join Date: Apr 2002
Real name: Bastien
Thx for it Filburt, but we can't consider it as mistakes ... it's just better if you don't work alone, so it is clearer for everybody

I'll take care for it in the future
Reply With Quote
  #3  
Old 27 Apr 2003, 21:40
Brad Brad is offline
 
Join Date: Nov 2001
A very good read.
Reply With Quote
  #4  
Old 27 Apr 2003, 21:58
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Today at 03:32 PM grog6 said this in Post #2
Thx for it Filburt, but we can't consider it as mistakes ... it's just better if you don't work alone, so it is clearer for everybody

I'll take care for it in the future
It's still a good habit to use for when you look back on your code a few months later and think "what the hell was I doing right here?"
Reply With Quote
  #5  
Old 27 Apr 2003, 23:26
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Real name: Dave
format of your code is a biggy... and fro some langiages can be a bloody joke.. ie truebasic , tho i have to admit ive seen a fair few php scripts that over look putting braces on new lines etc.

Its amazing how annoying something like that can be sometimes
Reply With Quote
  #6  
Old 28 Apr 2003, 14:43
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Real name: Dean Clatworthy
Good tips there filburt

- miSt
__________________
Dean Clatworthy - Web Developer/Designer
Reply With Quote
  #7  
Old 28 Apr 2003, 17:20
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
everyone started coding in a crappy style i think, but it's improving.

vb3 will follow these standarts above
Reply With Quote
  #8  
Old 28 Apr 2003, 19:39
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Real name: Dean Clatworthy
Well i found out all about indenting by accident in my text editor today. It does it all automatically so...

- miSt
__________________
Dean Clatworthy - Web Developer/Designer
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 08:01.

Layout Options | Width: Wide Color: