x + + Coding standards [MSDN AX 2012]

Source: Internet
Author: User
Tags coding standards microsoft dynamics

The best practice principles for writing X + + advocated by MS Dynamics Ax are still very useful for reference. So review and understand the new and borrowed to remember.

General coding principles for Microsoft Dynamics AX.

  • Declare variables as locally as possible.
  • Check the error conditions in the beginning; Return/abort as early as possible.
  • There are only one successful return point in the code (typically, the last statement), with the exception of switch cases, or When checking for start conditions.
  • Keep the building Blocks (methods) small and clear. A method should do a, well-defined job. It should therefore is easy to name a method.
  • Put braces around every block of statements, even if there is only one statement in the block.
  • Put comments in your code, telling others "what's the code is supposed to do, and" What's the parameters for.
  • Do not assign values to, or manipulate, actual parameters that is "supplied" by value. You should all able to trust, the value of such a parameter is the one initially supplied. Treat such parameters as constants.
  • Clean up your code; Delete unused variables, methods and classes.
  • Never let the user experience a runtime error. Take appropriate actions to either manage the situation programmatically or throw a error informing the user in the I Nfolog about the problem and what actions can is taken to fix the problem.
  • Never make assignments to the ' this ' variable.
  • Avoid dead Code. Reuse code. Avoid using the same lines of code in numerous places. Consider moving them to a method instead.
  • Never use Infolog.add directly. Use the indirection methods:error, warning, info and checkfailed.
  • Design your application to avoid deadlocks.

Happy cnblogging:)

x + + Coding standards [MSDN AX 2012]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.