TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  CFL#023

This rule is Obsolete
Synopsis:Do not use selection statements (if, switch) instead of a simple assignment or initialization
Language:C++
Severity Level:9
Category:Control Flow


Description:

Express your intentions directly. For example, for booleans do not write

bool pos;
if (val > 0)
{
    pos = true;
}
else
{
    pos = false;
}

but instead write

bool pos;
pos = (val > 0);	// single assignment

or even better

bool pos = (val > 0);	// initialization

This way of writing code improves the unit test coverage.