-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacade_dummy.py
56 lines (45 loc) · 1.23 KB
/
facade_dummy.py
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
"""
Provide a unified interface to a set of interfaces in a subsystem.
Facade defines a higher-level interface that makes the subsystem easier
to use.
"""
class Facade:
"""
Know which subsystem classes are responsible for a request.
Delegate client requests to appropriate subsystem objects.
"""
def __init__(self):
self._subsystem_1 = Subsystem1()
self._subsystem_2 = Subsystem2()
def operation(self):
self._subsystem_1.operation1()
self._subsystem_1.operation2()
self._subsystem_2.operation1()
self._subsystem_2.operation2()
class Subsystem1:
"""
Implement subsystem functionality.
Handle work assigned by the Facade object.
Have no knowledge of the facade; that is, they keep no references to
it.
"""
def operation1(self):
pass
def operation2(self):
pass
class Subsystem2:
"""
Implement subsystem functionality.
Handle work assigned by the Facade object.
Have no knowledge of the facade; that is, they keep no references to
it.
"""
def operation1(self):
pass
def operation2(self):
pass
def main():
facade = Facade()
facade.operation()
if __name__ == "__main__":
main()