Bendrinti naudojant


Best Practices for Constructors

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

Following is information about how to create a clean inheritance model and minimize problems when code is upgraded:

  • Each class must have a single public construction method unless the class is abstract. If no initialization is required, use a static construct method. Otherwise, use a static new… method (the default constructor (new method) for the class should be protected).

  • Each class should have at least one static construct method method. Warning icon

  • Each class should have at least one static new… method.

  • Each class should have a new method (the default constructor). This method should be protected. Warning icon

  • Create accessor methods to get and set class variables.

  • Create init methods to carry out any specialized initialization tasks that should be carried out after instantiation.

See also

Best Practices for Class Declarations

Best Practice for Destructors (finalize)

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