Merge pull request #173 from christianbraeunlich/merge-blank-lines-best-practices

[Best Practice] Merge into one Blank Lines topic
This commit is contained in:
Henrik Helgesen 2022-05-16 11:39:20 -07:00 committed by GitHub
commit f6a86eb60f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 129 deletions

View file

@ -1,60 +0,0 @@
---
title: "When not to use Blank Lines"
tags: ["AL","Readability"]
categories: ["Best Practice"]
---
Do not use blank lines:
- at the beginning or end of any functions (after `begin` and before `end`)
- inside multiline expressions
## Example 1
### Bad code
```al
procedure MATRIX_OnDrillDown(MATRIX_ColumnOrdinal: Integer);
begin
SetupDrillDownCol(MATRIX_ColumnOrdinal);
DrillDown(false, ValueType);
end;
```
### Good code
```al
procedure MATRIX_OnDrillDown(MATRIX_ColumnOrdinal: Integer);
begin
SetupDrillDownCol(MATRIX_ColumnOrdinal);
DrillDown(false, ValueType);
end;
```
## Example 2
### Bad code
```al
if NameIsValid and
Name2IsValid
then
```
### Good code
```al
if NameIsValid and
Name2IsValid
then
```
## Tips
The [AZ AL Dev Tools/AL Code Outline](https://marketplace.visualstudio.com/items?itemName=andrzejzwierzchowski.al-code-outline) extension adds two new commands to Visual Studio Code to remove empty duplicate lines.
- `Remove Empty Lines from the Active Editor` : removes empty duplicate lines from the current editor
- `Remove Empty Lines from the Active Project` : removes empty duplicate lines from the current project

View file

@ -1,48 +1,38 @@
---
title: "Avoid too many blank lines"
title: "When not to use Blank Lines"
tags: ["AL","Readability"]
categories: ["Best Practice"]
---
## Description
Avoid too many blank lines.
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
```al
var
UserSetup: Record "User Setup";
IsEditable: Boolean;
IsVisible: Boolean;
local procedure Initialize()
procedure MATRIX_OnDrillDown(MATRIX_ColumnOrdinal: Integer);
begin
IsEditable := false;
IsVisible := false;
SetupDrillDownCol(MATRIX_ColumnOrdinal);
DrillDown(false, ValueType);
UserSetup.Get();
end;
```
### Good code
```al
var
UserSetup: Record "User Setup";
IsEditable: Boolean;
IsVisible: Boolean;
local procedure Initialize()
procedure MATRIX_OnDrillDown(MATRIX_ColumnOrdinal: Integer);
begin
IsEditable := false;
IsVisible := false;
UserSetup.Get();
SetupDrillDownCol(MATRIX_ColumnOrdinal);
DrillDown(false, ValueType);
end;
```
@ -51,59 +41,18 @@ end;
### Bad code
```al
page 50000 "Blank Lines"
{
PageType = List;
ApplicationArea = All;
UsageCategory = Administration;
SourceTable = Customer;
if NameIsValid and
layout
{
area(Content)
{
repeater(GroupName)
{
ShowCaption = false;
field(Name; Rec.Name)
{
ApplicationArea = All;
}
}
}
}
}
Name2IsValid
then
```
### Good code
```al
page 50000 "Blank Lines"
{
PageType = List;
ApplicationArea = All;
UsageCategory = Administration;
SourceTable = Customer;
layout
{
area(Content)
{
repeater(GroupName)
{
ShowCaption = false;
field(Name; Rec.Name)
{
ApplicationArea = All;
}
}
}
}
}
if NameIsValid and
Name2IsValid
then
```
## Example 3