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.
Look at this demo on YouTube!
The link is pointing to
How to OMA - Setting break points in the where used functionality
Thanks, fixed it!
I think your example is wrong. After an IF statement the next line should be indented 2 spaces, not 3.
This is also how TAB works in the editor.
Yes, after an IF statement the indent is 2 spaces.
But when an IF statement is broken the indent is 3 spaces.
Ah yes, you are correct. This is incorrect in a lot of places in NAV.
With the knowledge they have at MDCC they should have made an indent "checker" two decades ago.
This is one area of the programming guide that changed, (somewhere around ver. 2 I think) I think also there was a slight indent change with CASE, I can say that I am also guilty of sometimes only using 2 spaces to indent, especially when modifying existing code.
Also doesn't the 3 space indent apply to assignment as well?
Assignments have also a 2 space indent.
The IF uses 3 spaces because of the length of IF. If you break a WHILE or UNTIL the indent is 6.
Beside of that you can use 2 extra spaces in a broken IF statement when you have an open '('.
MS Dev team is following 2 spaces only even after broken IF statements..
You will find the same thing in all places..
Exactly, and that's why they should use the OMA to correct it. :)
I've ran a little script to count it in all objects under 50.000. I'm happy to see that they do it right most of the times!
Indent 2: 778 times
Indent >2: 2.636 times