Actions

EmSys

CCoding Style - Donot comment Bad code-rewrite it

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)

Don’t comment Bad code, rewrite it

Comment anything unusual or potentially confusing, but when the comment outweighs the code, the code probably needs fixing.

/* If “result” is non-zero so return false(zero) */
#ifdef DEBUG
    printf(*** isword returns !result = %d\n”, !result );
    fflush(stdout);
#endif
return (!result);

Re-write it

#ifdef DEBUG
    printf(*** isword returns matchfound = %d\n”, matchfound );
    fflush(stdout);
#endif
return matchfound;