alguidelines/content/docs/BestPractices/blank-lines/index.md
Christian Bräunlich afc1d64ad6 updated blank lines
2022-04-15 12:59:51 +00:00

1.5 KiB

title tags categories
When not to use Blank Lines
AL
Readability
Best Practice

Description

Do not use blank lines:

  • at the beginning or end of any functions (after begin and before end)
  • inside multiline expression
  • after blank lines

Example 1

Bad code

procedure MATRIX_OnDrillDown(MATRIX_ColumnOrdinal: Integer);
begin

    SetupDrillDownCol(MATRIX_ColumnOrdinal);
    DrillDown(false, ValueType);

end;

Good code

procedure MATRIX_OnDrillDown(MATRIX_ColumnOrdinal: Integer);
begin
    SetupDrillDownCol(MATRIX_ColumnOrdinal);
    DrillDown(false, ValueType);
end;

Example 2

Bad code

if NameIsValid and

    Name2IsValid
then

Good code

if NameIsValid and
    Name2IsValid
then

Example 3

Bad code

var
    GLSetup: Record "General Ledger Setup";
    GLSetupRead: Boolean;


local procedure GetGLSetup()
begin
    if not GLSetupRead then
        GLSetup.Get();


    GLSetupRead := true;


    OnAfterGetGLSetup(GLSetup);
end;


[IntegrationEvent(false, false)]
local procedure OnAfterGetGLSetup(var GLSetup: Record "General Ledger Setup")
begin
end;

Good code

var
    GLSetup: Record "General Ledger Setup";
    GLSetupRead: Boolean;

local procedure GetGLSetup()
begin
    if not GLSetupRead then
        GLSetup.Get();

    GLSetupRead := true;

    OnAfterGetGLSetup(GLSetup);
end;

[IntegrationEvent(false, false)]
local procedure OnAfterGetGLSetup(var GLSetup: Record "General Ledger Setup")
begin
end;