Compartir a través de


X++ Standards: Comments

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Use // for both single and multiline (block) comments. There should be a space between the "//" and the start of the comment.

Comments should be in US-English and start with an uppercase letter (unless the first word is a lowercase name).

Put comments on a separate line before the code they are describing. The only exception to this is when you are describing parameters. In this case, put one parameter per line, with the comment describing it to the right of the parameter.

When creating a multiline comment, do not write on the first or the last line of the comment (as shown in the following example).

For example:

// Single line comment

<code>

//

// Comment on multiple lines.

// Do not add text to 1st or last line of comment.

//

<code>

Comments should not include:

  • Dates

  • Names

  • Aliases

  • Version or layer references

  • Bug numbers – unless it is a workaround, or unless the code could appear inappropriate if you didn't know that it was for a bug fix.

  • Politically or culturally sensitive phrases

Note

If you put a comment at the start of the method to describe its purpose and use, you can use block comments (/* */).

Remove Commented-out Code from the Application

The Best Practice is that we don't ship a product with commented-out code, so any commented-out code should be removed.

Tip

To find comments in the source (both // .. and /* .. */), use the Find dialog to search for methods containing the text (regular expression): /[/\*]

See also

X++ Coding Standards

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.