Skip to content

Commit b36e630

Browse files
committed
BF: descriptors must be bound to class, not instance -- Revert "Adjustment to UI and Business logic for injecting dependencies"
This reverts commit 69b507b.
1 parent c5ce565 commit b36e630

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

3-tier.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def __get__(self, obj, klas):
1919
class BusinessLogic(object):
2020
""" Business logic holding data store instances """
2121

22-
def __init__(self, data):
23-
self.data = data
22+
data = Data()
2423

2524
def product_list(self):
2625
return self.data['products'].keys()
@@ -32,8 +31,8 @@ def product_information(self, product):
3231
class Ui(object):
3332
""" UI interaction class """
3433

35-
def __init__(self, logic):
36-
self.business_logic = logic
34+
def __init__(self):
35+
self.business_logic = BusinessLogic()
3736

3837
def get_product_list(self):
3938
print('PRODUCT LIST:')
@@ -54,9 +53,7 @@ def get_product_information(self, product):
5453

5554

5655
def main():
57-
data = Data()
58-
logic = BusinessLogic(data)
59-
ui = Ui(logic)
56+
ui = Ui()
6057
ui.get_product_list()
6158
ui.get_product_information('cheese')
6259
ui.get_product_information('eggs')
@@ -72,7 +69,7 @@ def main():
7269
# cheese
7370
# eggs
7471
# milk
75-
#
72+
#
7673
# (Fetching from Data Store)
7774
# PRODUCT INFORMATION:
7875
# Name: Cheese, Price: 2.00, Quantity: 10

0 commit comments

Comments
 (0)