Variables Declarations Order
Categories:
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;
Tips
The AZ AL Dev Tools/AL Code Outline extension adds two new commands to Visual Studio Code to sorts variables.
Sort Variables in the Active Editor
: sorts variables in the current editorSort Variables in the Active Project
: sorts variables in the current project
Last modified May 6, 2022: Added Tips section with link to VSCode extension (a1c53ccb)
by Frédéric Vercaemst