Page CodingStyle.

Style matters in code too

"If it looks like crap, it probably smells bad too." -- JeanHuguesRobert

My style

  • 2 spaces indentation. Never use tab to indent. BTW: Tabs align on 8 chars limits.
  • 79 characters per line. Monospace font. I like Proggy Tiny.
  • If a line is the continuation of the previous line, make it visible on the continuation line. Example:
    • this = something
    • + something_else;
    • abc( kulg, koopip, woxi
    • , fdf, q);
  • A general rule is that space is THE best separator:
  • if( expr ){ code }else{ code }
  • while( expr ){ code }
    • i.e. because the parenthesis and {} belong to the control structure, glue them, i.e. don't put a space in the middle of a "word". Also:
  • if( xorb
  • && folg
  • ){
  • Definition time versus invokation time
    • function( pok ){ code } 2 spaces, before & after
    • abc(); abc( klo); 1 space, before parameters
    • abc( param1, param2); // 1 space before each parameter actually
  • Global/Local
    • Global
    • local
    • If using a pretty printer, have comments standout, i.e. have them be more visibible than the code, you will look at comments differently, they will focus the attention

Others

  • Jason Lamport. He agrees that important stuff should be at the beginning of the line.

Technics

  1. Have a lot of trace messages, categorized
  2. Keep them
    • You need an efficient implementation
  3. See also my DebugDarling

PAGE PRECEDENTE

PAGE PRECEDENTE

PAGE PRECEDENTE

PAGE PRECEDENTE

PAGE PRECEDENTE

PAGE PRECEDENTE

Wiki : 2007-11-11 23h02 par JeanHuguesRobert | autres changements
visites. ©2006-2008 Virteal
Feedback Form