procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
begin
AResponse.Content := 'Hello, World!';
Handled := true;
end;
Why it has to be ARequest but not simply Request, request or simply req? What is the meaning of this `A` after all? ARequest = A request? or ARequest = Abstract request?
The leading
A in
ARequest and
AResponse convey, when referenced in the body of the implemented procedure/function, that we are dealing with a passed parameter, not a procedure var or protected fields. If dealing with more than 10 lines in a procedure, this hint is very useful.
Sadly, this convention is not applied everywhere thus you find declaration like :
function TWin32WidgetSet.EnableWindow(HWnd: HWND; BEnable: Boolean): Boolean;
This makes it difficult to differenciate, in the EnableWindow function, if one is dealing with a parameter or a type, this did (maybe still so) confuse the debugger.
Had it been defined :
function TWin32WidgetSet.EnableWindow(aHWnd: HWND; aEnable: Boolean): Boolean;
It would be much clearer in the body of the function that
aHWnd is accessing the passed parameter
value.
I have a personal convention to define, for example, any record definition this way :
type
RUInt128 = record
Private
FValue : record
case boolean of
false: (CurrencyA : array[0..1] of Currency);
true: (QW64a : array[0..1] of QWord);
end;
FNeg : boolean;
function GetValue : Currency;
procedure SetValue(aCurrency : Currency);
public
property AsCurrency : Currency read GetCurrency write SetValue;
end;
This gives the following informations when dealing with this type :
The leading
R for the record name means, in a procedure that would declare it, that it exists on stack storage of the procedure and will disappear when the procedure exits.
FValue,
FNeg (private) are 2 fields that should only be accessed/modified directly in the unit implementation. This is generally enforced in delphi / FPC / Lazarus.
A private convention is that the
A /
a trailing character in Currency
A / QW64
a are arrays fields, it makes things easier to figure out when they appear in the code.
These conventions, once you figure which ones are applied since they are just naming conventions, help a great deal in understanding code and long term may make the difference between maintainable code or seemingly obfuscated code that will die if buggy.
In any case, having GOOD NAMES for class / variable / field / methods / etc... is not easy and often takes time in development. If the application to write is not trivial, determining names is part of a project analysis, they may be defined by the designers before the first line of code is written.