Skip to content

Instantly share code, notes, and snippets.

@viniciussanchez
Created April 15, 2021 11:15
Show Gist options
  • Save viniciussanchez/e6990b389f6014a1e02d9f2c8dc43948 to your computer and use it in GitHub Desktop.
Save viniciussanchez/e6990b389f6014a1e02d9f2c8dc43948 to your computer and use it in GitHub Desktop.
Violação do OCP (SOLD)
unit Solid.OCP.Violacao;
interface
type
TBancoItau = class
public
procedure GerarBoleto;
end;
TBancoCaixa = class
public
procedure GerarBoleto;
end;
TBoleto = class
public
procedure Gerar(const ABanco: TObject);
end;
implementation
procedure TBoleto.Gerar(const ABanco: TObject);
begin
if not Assigned(ABanco) then
Exit;
if ABanco.InheritsFrom(TBancoItau) then
TBancoItau(ABanco).GerarBoleto
else if ABanco.InheritsFrom(TBancoCaixa) then
TBancoCaixa(ABanco).GerarBoleto;
end;
procedure TBancoItau.GerarBoleto;
begin
end;
procedure TBancoCaixa.GerarBoleto;
begin
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment