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.


Look at this demo on YouTube!

Explore posts in the same categories: Check Guidelines, Object Manager

5 Comments on “Stick to the Guidelines!!”

  1. Natalie Says:

    According to 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.

  2. Reijer Molenaar Says:

    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.

  3. Ralf Dübsch Says:

    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.

  4. Reijer Molenaar Says:

    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.

  5. Natalie Says:

    Thanks for the feedback, Reijer!
    Still wondering why Microsoft works against its own two-space-indent rule …


To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word