Stick to the Guidelines!!
In my opinion all NAV developers should write code in a way that it’s easy to read for other developers. There is only one way to do that: Stick as close as possible to the coding standards that are described in the “C/AL Programming Guide”.
No Hungarian Notation, no strange indentation or other strange constructions. All these abnormalities makes it hard for others to read.
One tool of the OMA can help you with that. The “Check Guidelines Tool” finds 64 of the most made mistakes. And it even can fix a lot of them. I just ran it over a non customized Cronus database and it found 26.838 coding flaws that can be autocorrected by the OMA. Please NAV Development center in Vedbæk, get of copy of the OMA and use it for only 15 minutes to correct all these flaws.
Let’s take codeunit 6814 EP Encode XML. This one is really bad. It has 577 guidelines errors that can be corrected by the OMA. Please take a look at the picture.
Explore posts in the same categories: Check Guidelines, Object Manager
July 13th, 2012 at 12:57 pm
According to http://msdn.microsoft.com/en-us/library/ee414237.aspx your used guideline seems to be outdated. I refer to the example of IF NOT SETCURRENTKEY where in the new guideline the indentation of the secon line must be 2 instead of 3.
So if I am not wrong, OMA should be fixed.
July 13th, 2012 at 1:28 pm
Yes indeed, it seems you’re right. This comes quite as a shock to me!!
However, I cannot find this 2 indent a single time in the new NAV2013 database. You would almost say that someone made a mistake when he wrote this new guideline document…
I will ask Microsoft what’s the right way to break an if statement.
July 13th, 2012 at 8:44 pm
It would be a big surprise to me if the mentioned document is really valid in this case. To me it doesn’t make any sense to start a new indentation “tradition” for IFs…
And something’s fishy on the website. You see it in section “Order in Expressions”. There the code in the YES CASE is badly indented.
July 14th, 2012 at 11:19 am
Natalie, I just got a confirmation that they made a mistake in the new document. The 3 space indent is the right way to do it. And Ralph, I also reported the wrong CASE statement so it will probably be corrected.
July 16th, 2012 at 8:35 am
Thanks for the feedback, Reijer!
Still wondering why Microsoft works against its own two-space-indent rule …