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

Rule:  INT#009

This rule is Obsolete
Synopsis:Do not use special values for don't care parameters
Language:C++
Severity Level:9
Category:Class Interface


Description:

Under certain circumstances one or more parameters of a function or method call are not relevant. A solution can be to define a special value for such a situation, as in:

// Not allowed !!!
void
SetSpeedAndDirection(
    const ULONG ulSpeed,
    const ULONG ulDirection)
{
    ...
}

SetSpeedAndDirection(100, ulDirectionDontCare);

This is not allowed. Instead, if a parameter can be "don't care" a flag must be added to the interface or additional methods must be added, as in:

// OK
void
SetSpeedAndDirection(
    const ULONG ulSpeed,
    const BOOL  bSpeedValid,
    const ULONG ulDirection,
    const BOOL  bDirectionValid);

or alternatively:

// OK
void
SetSpeed(
    const ULONG ulSpeed);

void
SetDirection(
    const ULONG ulDirection);