Actions

EmSys

CCoding Style - Clarify-donot-confuse2

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)

Clarify, don’t confuse ...

  • When it takes more than a few words to explain what’s happening, it’s often an indication that the code should be rewritten.
  • Here, the code could perhaps be improved but the real problem is the comment, which is nearly as long as the implementation and confusing, too.
/* strcmp : return < 0 if s1 < s2, > 0 if s1 > s2, 0 if equal */
int strcmp( char* s1, char* s2 )
{
    . . .
}