Encapsulate behavior and control access
Procedures turn language statements into named behavior. Access modifiers and object boundaries determine which callers may depend on that behavior.
Design procedure contracts
A procedure signature should state what the caller supplies, what the procedure returns, and which values it changes. Use domain-specific names and types so the caller doesn't need to know the implementation.
procedure ImportItemReviews(SourceName: Text; SourceStream: InStream): Guid
This signature exposes an import operation and returns a batch identifier. It doesn't expose the temporary CSV buffer, row counters, or parsing helpers used inside the implementation.
Use overloads only when variants perform the same conceptual operation. Use built-in methods such as Record.Get, Record.Validate, and InStream.ReadText instead of recreating platform behavior. Before you call an unfamiliar method, inspect its signature and runtime requirements in AL Explorer, IntelliSense, or the AL method reference.
Choose procedure visibility deliberately
AL procedure access modifiers establish a boundary inside an object:
locallimits a procedure to the object that declares it.internalallows code in the same extension to call the procedure.protectedallows access from the declaring object and objects that extend it.publicallows dependent extensions to call the procedure.
Public is the default procedure access, but it shouldn't be the default design choice. Every public procedure becomes an interface that another extension can depend on. Keep parsing, validation, and formatting helpers local unless callers have a stable reason to use them.
procedure ImportItemReviews(SourceName: Text; SourceStream: InStream): Guid
begin
exit(ImportRows(SourceName, SourceStream));
end;
local procedure ImportRows(SourceName: Text; SourceStream: InStream): Guid
begin
// Parse rows and coordinate updates.
end;
Set object and extension boundaries
The Access property controls whether another extension can reference an object. Set Access = Internal on an implementation codeunit when its object identity isn't part of the supported contract. A separate public façade can expose a small set of stable procedures.
codeunit 70900 "Item Review Import Impl."
{
Access = Internal;
procedure Import(SourceName: Text; SourceStream: InStream): Guid
begin
// Internal implementation.
end;
}
An internal boundary protects callers from implementation changes, but it isn't a security boundary. Permission sets and entitlements govern whether a user may access data and execute objects.
For test or companion extensions, InternalsVisibleTo in app.json can grant a named extension access to internal objects. Use that exception intentionally, and keep the public contract small.
For more information, see Access property and Access modifiers in AL.