Update AL coding guidelines to use PascalCase for variable and function names

- Corrected naming conventions in the AL code style documentation to specify PascalCase instead of camelCase for variables and functions.
- Adjusted examples throughout the documentation to reflect the updated naming conventions.
- Enhanced clarity in performance guidelines by renaming procedures for better understanding.
This commit is contained in:
Dmitry Katson 2025-07-30 22:08:25 +08:00
parent 6b3f522a16
commit 2a805b20dc
6 changed files with 15 additions and 16 deletions

View file

@ -11,7 +11,7 @@ alwaysApply: true
These rules ensure consistent code structure and organization across AL projects, making code more maintainable and AI-assistant friendly. These rules ensure consistent code structure and organization across AL projects, making code more maintainable and AI-assistant friendly.
## Style guidelines for AL code ## Style guidelines for AL code
- Always use camelCase for variable and function names. - Always use PascalCase for variable and function names.
- Use PascalCase for object names (e.g., tables, pages, reports). - Use PascalCase for object names (e.g., tables, pages, reports).
- Maintain a consistent indentation style (2 spaces preferred). - Maintain a consistent indentation style (2 spaces preferred).
@ -22,7 +22,7 @@ These rules ensure consistent code structure and organization across AL projects
## Rule 1: Consistent Indentation and Formatting ## Rule 1: Consistent Indentation and Formatting
### Intent ### Intent
Maintain consistent code formatting to improve readability and enable better AI understanding of code structure. Use 2-space indentation consistently throughout your project and maintain consistent formatting within functions and procedures. Maintain consistent code formatting to improve readability and enable better AI understanding of code structure. Use indentation with two spaces consistently throughout your project and maintain consistent formatting within functions and procedures.
### Examples ### Examples

View file

@ -22,10 +22,10 @@ Implement proper event patterns to enable extensibility without modifying base a
codeunit 50100 "Sales Document Events Handler" codeunit 50100 "Sales Document Events Handler"
{ {
[EventSubscriber(ObjectType::Table, Database::"Sales Header", OnBeforeInsert, '', false, false)] [EventSubscriber(ObjectType::Table, Database::"Sales Header", OnBeforeInsert, '', false, false)]
local procedure OnBeforeInsertSalesHeader(var Rec: Record "Sales Header"; RunTrigger: Boolean) local procedure OnBeforeInsertSalesHeader(var SalesHeader: Record "Sales Header"; RunTrigger: Boolean)
begin begin
// Custom validation logic // Custom validation logic
ValidateCustomFields(Rec); ValidateCustomFields(SalesHeader);
end; end;
} }
``` ```

View file

@ -36,7 +36,7 @@ The following rule sets provide comprehensive guidance for AL development:
## Key Guidelines Summary ## Key Guidelines Summary
- **File Naming**: Use `<ObjectName>.<ObjectType>.al` pattern consistently - **File Naming**: Use `<ObjectName>.<ObjectType>.al` pattern consistently
- **Code Style**: Use 2-space indentation and camelCase for variables, PascalCase for objects - **Code Style**: Use two space indentation and PascalCase for variables, PascalCase for objects
- **Folder Structure**: Organize by feature (`src/feature/subfeature/`) not by object type - **Folder Structure**: Organize by feature (`src/feature/subfeature/`) not by object type
- **Performance**: Filter data early, use temporary tables, avoid unnecessary loops - **Performance**: Filter data early, use temporary tables, avoid unnecessary loops
- **Events**: Prefer integration events over direct modifications for extensibility - **Events**: Prefer integration events over direct modifications for extensibility

View file

@ -65,24 +65,24 @@ SalesPostingTests.Codeunit.al
## Rule 3: Variable and Function Naming ## Rule 3: Variable and Function Naming
### Intent ### Intent
Use consistent naming conventions for variables and functions to improve code readability. Use camelCase for variable and function names, descriptive names that clearly indicate purpose, and avoid abbreviations unless they are well-known business terms. Use consistent parameter naming in procedures. Use consistent naming conventions for variables and functions to improve code readability. Use PascalCase for variable and function names, descriptive names that clearly indicate purpose, and avoid abbreviations unless they are well-known business terms. Use consistent parameter naming in procedures.
### Examples ### Examples
```al ```al
// Good examples - Variables // Good examples - Variables
var var
customerLedgerEntry: Record "Cust. Ledger Entry"; CustomerLedgerEntry: Record "Cust. Ledger Entry";
totalAmount: Decimal; TotalAmount: Decimal;
discountPercentage: Decimal; DiscountPercentage: Decimal;
isValidTransaction: Boolean; IsValidTransaction: Boolean;
``` ```
```al ```al
// Good examples - Functions // Good examples - Functions
procedure calculateCustomerBalance(customerNo: Code[20]): Decimal procedure CalculateCustomerBalance(CustomerNo: Code[20]): Decimal
procedure validateSalesDocument(var salesHeader: Record "Sales Header") procedure ValidateSalesDocument(var SalesHeader: Record "Sales Header")
procedure updateInventoryQuantity(itemNo: Code[20]; quantity: Decimal) procedure UpdateInventoryQuantity(ItemNo: Code[20]; Quantity: Decimal)
``` ```
## Rule 4: Parameter Naming in Event Subscribers ## Rule 4: Parameter Naming in Event Subscribers

View file

@ -26,7 +26,7 @@ Optimize queries by filtering data as early as possible to reduce data transfer
```al ```al
// Good example - Early filtering // Good example - Early filtering
procedure GetCustomersByCity(CityFilter: Text): Integer procedure GetNumberOfCustomersByCity(CityFilter: Text): Integer
var var
Customer: Record Customer; Customer: Record Customer;
begin begin
@ -43,7 +43,7 @@ end;
```al ```al
// Bad example (avoid processing all records) // Bad example (avoid processing all records)
procedure GetCustomersByCity(CityFilter: Text): Integer procedure GetNumberOfCustomersByCity(CityFilter: Text): Integer
var var
Customer: Record Customer; Customer: Record Customer;
Count: Integer; Count: Integer;

View file

@ -169,7 +169,6 @@ Organize test files to mirror the application structure while maintaining clear
- Use same feature-based organization for tests - Use same feature-based organization for tests
- Place shared test utilities in Common folder - Place shared test utilities in Common folder
- Maintain consistent naming patterns - Maintain consistent naming patterns
- When creating test files, mirror the feature organization of the App project but place all tests in the Test project structure
### Examples ### Examples