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

Rule:  CFL#023

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


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

bool pos;
if (val > 0)
    pos = true;
    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.