web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

What is the best practice for naming variables in standard class and newly created class?

(0) ShareShare
ReportReport
Posted on by 1,552

If i create a new table and name it with ModelNameTableName ex:  XXTable and put fields field1,field1

if i use this table in a new class that i created ex: XXclassName, if i want to use the table in this class do i need to name the variable with XX

i mean XXTable xxTable; or can i do it XXTable table; 

what is the best practice for this?

Also if use this new table in a standard class should i name the variable

XXTable xxTable;  or  XXTable table; ???

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    The most important thing is to use your prefix / suffix. You can check Microsoft's recommendations here: docs.microsoft.com/.../naming-guidelines-extensions

    The reason why you should use prefix/suffix is to avoid conflicts with future MS updates, and other customizations / ISV solutions.

    You should also use prefix/suffix it when adding new variables to standard classes. Otherwise there could be a conflict if Microsoft adds a variable with the same name.

    So, whenever you are adding something that could have a naming confict with future MS updates, you need to use your prefix/suffix:

    - All new objects

    - All elements in table/form/entity extension

    - All methods and class variables in class augmentation, as well as child classes of standard classes

  • junior AX Profile Picture
    1,552 on at

    So if i created the class(not standard)

    There is no need to name the variable of XXTable with xxtable as this should not conflict with MS but it won't hurt to do it?

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Inside your class you don't need to use any prefix/suffix for variable or method names. It doesn't hurt but I would not do it.

  • Blue Wang Profile Picture
    on at

    Hi  Junior,

    Variables of specialized types (extended data types) should have the same name as the type (which should have a logical name) but starting with a lower case character.

    If you have more than one variable of the same specialized type, use logical names that contain the name of the type as a prefix.

    Please read this: docs.microsoft.com/.../naming-conventions-variables

  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I would avoid including prefixes in variable names, unless there is a reason to do that (e.g. if you have XxxCustTable and remove the prefix, it would look like the variable is of type CustTable instead of XxxCustTable).

    Your goal should be writing code that is easy to read, and these prefixes makes names longer (typically) without adding any value, therefore they decrease quality of code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans