-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacade.py
More file actions
58 lines (38 loc) · 1008 Bytes
/
facade.py
File metadata and controls
58 lines (38 loc) · 1008 Bytes
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
#!/usr/bin/env python3
# @file: facade.py
# @auth: sprax
# @date: 2021-10-16 22:31:42 Sat 16 Oct
# Sprax Lines 2016.07.12 Written with Python 3.5
'''
Facade v. Proxy v. Adaptor v. (In)formal Interface
'''
class Interface():
''' base class '''
# def __init__(self, name):
# self.name = name
def hi(self):
pass
class ImplOne(Interface):
''' derived class '''
def __init__(self, name1):
# super().__init__(name1)
self.name = name1
def hi(self):
print("Howdy, I'm %s!" % self.name)
class ImplTwo(Interface):
''' derived class '''
def __init__(self, name1, name2):
# super().__init__(name1)
self.name = name1 + " " + name2
def hi(self):
print("Hi hi, I'm %s!" % self.name)
class PrefixMixin(object):
''' prefix mixin class '''
pass
def main():
imp1 = ImplOne("joe")
imp1.hi()
imp2 = ImplTwo("jerry", "hall")
imp2.hi()
if __name__ == '__main__':
main()