home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / papers / misc / cs.toronto.edu:programming / ten-commandments < prev   
Encoding:
Text File  |  1992-10-18  |  2.5 KB  |  59 lines

  1.            The Ten Commandments for C Programmers
  2.  
  3.                        Henry Spencer
  4.  
  5. 1    Thou shalt run _l_i_n_t frequently and study its pronounce-
  6.      ments  with  care, for verily its perception and judge-
  7.      ment oft exceed thine.
  8.  
  9. 2    Thou shalt not follow the NULL pointer, for  chaos  and
  10.      madness await thee at its end.
  11.  
  12. 3    Thou shalt cast all function arguments to the  expected
  13.      type  if  they  are not of that type already, even when
  14.      thou art convinced that this is unnecessary, lest  they
  15.      take  cruel  vengeance upon thee when thou least expect
  16.      it.
  17.  
  18. 4    If thy header files fail to declare the return types of
  19.      thy  library functions, thou shalt declare them thyself
  20.      with the  most  meticulous  care,  lest  grievous  harm
  21.      befall thy program.
  22.  
  23. 5    Thou shalt  check  the  array  bounds  of  all  strings
  24.      (indeed,  all  arrays),  for  surely  where thou typest
  25.      ``foo'' someone someday shall type ``supercalifragilis-
  26.      ticexpialidocious''.
  27.  
  28. 6    If a function be advertised to return an error code  in
  29.      the  event  of  difficulties, thou shalt check for that
  30.      code, yea, even though the checks triple  the  size  of
  31.      thy  code  and produce aches in thy typing fingers, for
  32.      if thou thinkest ``it cannot happen to me'',  the  gods
  33.      shall surely punish thee for thy arrogance.
  34.  
  35. 7    Thou shalt study thy libraries and strive  not  to  re-
  36.      invent  them  without cause, that thy code may be short
  37.      and readable and thy days pleasant and productive.
  38.  
  39. 8    Thou shalt make thy  program's  purpose  and  structure
  40.      clear  to  thy  fellow  man by using the One True Brace
  41.      Style, even if thou likest it not, for  thy  creativity
  42.      is  better  used  in  solving problems than in creating
  43.      beautiful new impediments to understanding.
  44.  
  45. 9    Thy external identifiers shall be unique in  the  first
  46.      six characters, though this harsh discipline be irksome
  47.      and the years of  its  necessity  stretch  before  thee
  48.      seemingly  without end, lest thou tear thy hair out and
  49.      go mad on that fateful day when thou desirest  to  make
  50.      thy program run on an old system.
  51.  
  52. 10   Thou shalt foreswear, renounce,  and  abjure  the  vile
  53.      heresy  which  claimeth that ``All the world's a VAX'',
  54.      and have no commerce with the  benighted  heathens  who
  55.      cling  to  this  barbarous belief, that the days of thy
  56.      program may be long even though the days of thy current
  57.      machine be short.
  58.  
  59.