-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathStructural.Facade.Pattern.pas
93 lines (74 loc) · 1.27 KB
/
Structural.Facade.Pattern.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
unit Structural.Facade.Pattern;
interface
type
TSystemA = class
private
function A1: string;
end;
TSystemB = class
private
function B1: string;
end;
TSystemC = class
private
function C1: string;
end;
TFacade = class
public
class procedure Operation1;
class procedure Operation2;
end;
implementation
{ TSystemA }
function TSystemA.A1: string;
begin
Result := 'System A, Method A1' + #10;
end;
{ TSystemB }
function TSystemB.B1: string;
begin
Result := 'System B, Method B1' + #10;
end;
{ TSystemC }
function TSystemC.C1: string;
begin
Result := 'System C, Method C1' + #10;
end;
{ TFacade }
class procedure TFacade.Operation1;
var
sysA: TSystemA;
sysB: TSystemB;
sysC: TSystemC;
begin
sysA := TSystemA.Create;
sysB := TSystemB.Create;
sysC := TSystemC.Create;
try
WriteLn('Operation 1' + #10 +
sysA.A1 +
sysB.B1 +
sysC.C1);
finally
sysA.Free;
sysB.Free;
sysC.Free;
end;
end;
class procedure TFacade.Operation2;
var
sysB: TSystemB;
sysC: TSystemC;
begin
sysB := TSystemB.Create;
sysC := TSystemC.Create;
try
WriteLn('Operation 1' + #10 +
sysB.B1 +
sysC.C1);
finally
sysB.Free;
sysC.Free;
end;
end;
end.