This documentation is archived and is not being maintained.
Dead Code Examples [AX 2012]
Updated: November 30, 2011
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.
In the following example, b++ is never reached:
a++;
return a;
b++;
return b;
In the following example, the break statement is never reached:
switch (type)
{
case UtilElementType::Job:
return false;
break;
...
In the following example, return a is never reached:
if (!a)
{
throw error("@SYS21628");
return a;
}
b++;
return b;
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;
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the
MS Press Store.