Actions

EmSys

CCoding Style - Use active names for functions

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Use active names for functions

  • Function names should be based on active verbs, perhaps followed by nouns.
now = getTime(); , putchar(‘m’); , etc
  • Functions that return a Boolean (true/false) value should be named so that the return value is unambiguous.
if( checkOctal( c ) ) 

doesn’t indicate which value is true and which is false, while

if( isoctal( c ) )  

makes it clear that the function returns true if the argument is octal and false if not.