Skip to content

função aninhada (nested funcion).#121

Merged
mobius1qwe merged 2 commits intoOpenSourceCommunityBrasil:devfrom
fortesm:dev
Mar 18, 2026
Merged

função aninhada (nested funcion).#121
mobius1qwe merged 2 commits intoOpenSourceCommunityBrasil:devfrom
fortesm:dev

Conversation

@fortesm
Copy link
Copy Markdown

@fortesm fortesm commented Mar 18, 2026

Centraliza criação.
Reduz duplicação.
Mantém escopo local.
Não alterar comportamento.
Mantém DRY (Dont Repeat Yourself).

Centraliza criação.
Reduz duplicação.
Mantém escopo local.
Não alterar comportamento.
Mantém DRY (Dont Repeat Yourself).
@fortesm
Copy link
Copy Markdown
Author

fortesm commented Mar 18, 2026

Pequena melhoria adicional (opcional, mas importante mas dependo de uma maior aprovação).
Posso deixar ainda mais limpo separando a lógica de recuperação, assim:

function TryGetSession(out ASession: TRALWebSession): Boolean;
begin
  Result := False;
  vSession := ARequest.Params.GetKind[RAL_SESSION, rpkCOOKIE];

  if vSession <> nil then
  begin
    vWesSessionName := vSession.AsString;
    ASession := TRALWebSession(FSessions.ObjectByItem(vWesSessionName));
    Result := ASession <> nil;
  end;
end;

E o fluxo:

if not TryGetSession(vWebSession) then
  vWebSession := CreateNewSession
else
  vWebSession.LastDate := Now;

Comment thread src/base/RALWebModule.pas Outdated
@mobius1qwe mobius1qwe added this to the 1.0 milestone Mar 18, 2026
@mobius1qwe mobius1qwe added vcs: Optimization When the issue enhances existing features without changing their functionality seg: Server Issues that happen on the Server side of the package sec: Web Issues that happen with the Web feature of the package labels Mar 18, 2026
@mobius1qwe mobius1qwe merged commit 506530c into OpenSourceCommunityBrasil:dev Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sec: Web Issues that happen with the Web feature of the package seg: Server Issues that happen on the Server side of the package vcs: Optimization When the issue enhances existing features without changing their functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants