Dead Code Examples
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
Avoid writing redundant code.
Example 1
In the following example, b++ is never reached:
a++;
return a;
b++;
return b;
Example 2
In the following example, the break statement is never reached:
switch (type)
{
case UtilElementType::Job:
return false;
break;
...
Example 3
In the following example, return a is never reached:
if (!a)
{
throw error("@SYS21628");
return a;
}
b++;
return b;
Example 4
In the following example, the else statement is never used, because execution has already ended at the return statement:
if (a)
{
return a;
}
else
{
b++;
return b;
}
Use this format instead:
if (a)
{
return a;
}
b++;
return b;
See also
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.