Share via


Dynamics AX Development and Customization Best Practices-Naming conventions

In previous article we have covered coding best practices of code formattings in this article we will cover the Naming conventions:

Naming conventions contribute to consistency and to making the application easier to understand. Naming conventions contribute to consistency and to making the application easier to understand. I think that the basic rule to create good naming conventions is to do it with following guidelines.

  • Use Camel Casing for member variables, method names, and local variables. E.g. serverClass;
  • Use Pascal Casing for AOT elements. E.g. AddressCountyRegion;
  • Prefix parameter names with an underscore (_). E.g. myJob(Args _args)
  • Do not use Hungarian notation. Do not encode the type of a variable in its name. E.g. strName
  • Avoid prefixing local variables. E.g. stringName or intCount
  • Use meaningful and self-documenting names.

Object names best practice:

Object names should not be hard-coded. If the objects are renamed or removed in future version, hard-coded names do not result in compilation errors and are very difficult to find.

It is always better to wrap object names in methods such as formstr(..) and tablestr(..), because they result in a compilation error and easily surface naming issues.

In this example, object names are hard-coded in code.

Args = new Args(‘SalesTable’);

methodName = ‘runXyz’;

In this example, object names are wrapped with correct methods.

Args = new Args(formstr(SalesTable));

methodName = tablemethodstr(SalesTable,runXyz);