Merge pull request #154 from christianbraeunlich/feature/guideline-blank-lines
Best Practice: Avoid too many Blank Lines
This commit is contained in:
commit
32ec19fcde
1 changed files with 159 additions and 0 deletions
159
content/docs/BestPractices/blank-lines/index.md
Normal file
159
content/docs/BestPractices/blank-lines/index.md
Normal file
|
|
@ -0,0 +1,159 @@
|
||||||
|
---
|
||||||
|
title: "Avoid too many blank lines"
|
||||||
|
tags: ["AL","Readability"]
|
||||||
|
categories: ["Best Practice"]
|
||||||
|
---
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Avoid too many blank lines.
|
||||||
|
|
||||||
|
## Example 1
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
|
```al
|
||||||
|
var
|
||||||
|
UserSetup: Record "User Setup";
|
||||||
|
IsEditable: Boolean;
|
||||||
|
IsVisible: Boolean;
|
||||||
|
|
||||||
|
|
||||||
|
local procedure Initialize()
|
||||||
|
begin
|
||||||
|
IsEditable := false;
|
||||||
|
IsVisible := false;
|
||||||
|
|
||||||
|
|
||||||
|
UserSetup.Get();
|
||||||
|
end;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Good code
|
||||||
|
|
||||||
|
```al
|
||||||
|
var
|
||||||
|
UserSetup: Record "User Setup";
|
||||||
|
IsEditable: Boolean;
|
||||||
|
IsVisible: Boolean;
|
||||||
|
|
||||||
|
local procedure Initialize()
|
||||||
|
begin
|
||||||
|
IsEditable := false;
|
||||||
|
IsVisible := false;
|
||||||
|
|
||||||
|
UserSetup.Get();
|
||||||
|
end;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example 2
|
||||||
|
|
||||||
|
### Bad 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example 3
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
|
```al
|
||||||
|
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
|
||||||
|
|
||||||
|
```al
|
||||||
|
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;
|
||||||
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue