Monday, October 19, 2015

Naming Conventions in Navision

One of the best programming skills every programmer needs to have is to follow the proper naming conventions of the application and also do proper documentation of the changes they are making.  Microsoft provided some naming conventions to follow for Dynamics NAV and please check the below link for more information

I have seen several times even a very good programmer fails to follow these simple naming conventions. I believe that  by following these simple rules not only helps the programmer who is doing programming but also other developers to understand the code easily, incase they have to support it later.
One trick I always use for naming variables especially for record or codeunit variables is if I am not sure what would be the name I have to use for my variable, then I will go and check in standard objects if that record or codeunit was used how it was named.
For example what do I name the variable if I have to declare a record of subtype Sales Header table,  in standard objects most of the time if you notice it will be named as SalesHeader and if you have to declare multiple then use SalesHeader2, SalesHeader3….. and so on.
One other important naming convention is to always use Temp before variable name if it is a temporary record.
For example: for the same sales header record variable if I set that as temporary then I use the variable name as TempSalesHeader
You have to follow the naming convention when naming functions, records, codeunits, field names, table names, control names and or so on….
Please leave your comments, feedback or any suggestions you have for me to improve me my blog and also if you have any questions, feel free to post..
Share:

2 comments:

Martin Hansen said...

Funny thing is that Microsoft's own naming convention does not mention how to name text variables or when to use global vs. local text variables. I have always used the 'old' TextXXX syntax. I very much like this syntax, because it is immediately apparent to the developer that this is in fact a text variable and not a 'regular' variable. It is also immediately apparent if it is a custom variable, or if it is a standard variable - if the developer uses the 50000 no. series for the naming that is.
In later versions of NAV more and more standard text variables are being changed to reflect the content of the message rather than the nature of the variable - eg. CU80 'Text062Qst' or CU99000854 'NextStateTxt' etc.
I really like the 'old' way better, but what I definitely do not like is to have a mix of both syntaxes in the same object. Microsoft - please make a convention for this ;-)

Suresh Kulla said...

Martin,

Even i like Textxxx syntax because it is easy to identify in the code that it is text constant, as you mentioned i noticed in fewer objects they started naming the Text constants differently instead of using Textxxx , and i totally agree using two different convention for the same does not look appropriate.
Thanks for sharing your thoughts on this.

Thanks
Suresh