|

 
|
| | Name : | Ian S. Piper | Organization : | Diebold Election Systems, Inc. | Post Date : | 9/29/2005 |
| Section : | .20.5.4.2 | Page no. : | (Vol 2) 5-10 | Line no.: | | Comment : | For the requirement in item (t), "Specifies explicit comparisons in all if() and while() conditions. For instance,
i. if(flag)
prohibited, and shall be written in the format
ii. if (flag == TRUE)"
, this requirement is logically incorrect for the C and C++ languages. The format has to be ' if (flag != FALSE) '. In C/C++, TRUE equals 1, but 'flag' is considered to be logically true if it is any nonzero value. Therefore you cannot test 'flag' against equivalence with 1; you must test for nonequivalence with 0.
This aside, the whole requirement serves no purpose other than to make the code less readable. Consider the following:
if (PointInRect(point)) …
versus
if (PointInRect(point) != FALSE) …
The first form reads much more naturally, that is, “If the point is in the rectangle”. With the second form, programmers constantly have to do a double-take. “If it is not false that the point is in the rectangle”.
Proposed change: Remove this requirement. | |
|
|