Variables Declarations Order

Created by Microsoft, Described by waldo

Description

Variables declarations should be ordered by type. In general, object and complex variable types are listed first followed by simple variables. The order should be:

  • Record
  • Report
  • Codeunit
  • XmlPort
  • Page
  • Query
  • Notification
  • BigText
  • DateFormula
  • RecordId
  • RecordRef
  • FieldRef
  • FilterPageBuilder

(Ref: Microsoft Docs)

Bad code

    StartingDateFilter: Text;
    Vendor: Record Vendor;

Good code

    Vendor: Record Vendor;
    StartingDateFilter: Text;

Discussions

You can find discussions on all “Best Practices” here.

If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.

Last modified February 24, 2022: Added tags & categories + cleanup (5ee04366)