-
-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathfacade_concept.py
56 lines (43 loc) · 1.38 KB
/
facade_concept.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
# pylint: disable=too-few-public-methods
"The Facade pattern concept"
class SubSystemClassA:
"A hypothetically complicated class"
@staticmethod
def method():
"A hypothetically complicated method"
return "A"
class SubSystemClassB:
"A hypothetically complicated class"
@staticmethod
def method(value):
"A hypothetically complicated method"
return value
class SubSystemClassC:
"A hypothetically complicated class"
@staticmethod
def method(value):
"A hypothetically complicated method"
return value
class Facade():
"A simplified facade offering the services of subsystems"
@staticmethod
def sub_system_class_a():
"Use the subsystems method"
return SubSystemClassA().method()
@staticmethod
def sub_system_class_b(value):
"Use the subsystems method"
return SubSystemClassB().method(value)
@staticmethod
def sub_system_class_c(value):
"Use the subsystems method"
return SubSystemClassC().method(value)
# The Client
# call potentially complicated subsystems directly
print(SubSystemClassA.method())
print(SubSystemClassB.method("B"))
print(SubSystemClassC.method({"C": [1, 2, 3]}))
# or use the simplified facade
print(Facade().sub_system_class_a())
print(Facade().sub_system_class_b("B"))
print(Facade().sub_system_class_c({"C": [1, 2, 3]}))