I have a class that has N methods for internal use and these N methods can be combined in random sequence inside of other execute methods.
class DummyOperator:
def step_1(self):
pass
.....
def step_n(self):
pass
def execute_1(self):
self.step_1()
self.step_5()
self.step_9()
self.step_2()
.....
def execute_m(self):
self.step_7()
self.step_6()
In some other file, there is call of one of these execute methods depending on cofig file
main.py
conf_value = get_value_from_config()
obj = DummyOperator()
execute_method = None
if conf_value == 'param_1':
execute_method = obj.execute_1
....
if conf_value == 'param_m':
execute_method = obj.execute_m
execute_method()
The problem that amount of execute methods is big and growing fast but decomposition of this class is not convenient because these N methods suite good for this logic entity. Also the system have bunch of such classes.
Can you please tell what is better approach to design such architecture and how dynamically can execute method of Operator class can be built at runtime?
Aucun commentaire:
Enregistrer un commentaire