Actions

EmSys

CCoding Style - Use the natural form for Expressions

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 the natural form for Expressions

  • Write expressions as you might speak them aloud
if( !(block_id < actblks) || !(block_id >= unblocks) )
  • Each test is stated negatively, though there is no need for either to be. Turning the relations around lets us state the tests positively.
If( (block_id >= actblks) || (block_id < unblocks) )
  • Now the code reads naturally.