X++ Standards: Constants [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
Follow the best practices rules about using constants. These are designed to make it easier to maintain X++ code.
|
Rule |
Error level |
|---|---|
|
Do not use hard-coded constants (except 0, 1, 100). |
Warning |
|
Define constants in a method, class declaration, or if necessary globally in a macro. Reuse existing constants. Consider alternative ways of getting the constant:
|
None |
|
Rule |
Error level |
|---|---|
|
User interface text must be in double quotes, and you must always use a label (also in double quotes). |
Error |
|
User interface labels must be complete sentences. Do not build sentences using more than one label, or other constants or variables under program control (do not use concatenation). Example: Description description = "@SYS12345" Use strFmt to format user interface text. |
None |
|
Rule |
Error level |
|---|---|
|
Always review the direct use of numeric constants, except for 0 meaning null, 1 meaning increment, and 100 when calculating percents and currencies. |
None |
|
Certain numeric constants are predefined, such as the number of days per week, and the number of hours per day. For example, see the TimeConstants and SysBitPos macros in the Application Object Tree (AOT). |
None |
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.