Good evening.
First of all I would like to apologize for the name of topic. I really didn't know how to name it more correctly.
I mostly develop on Python some automation scripts such as deployment (it'snot about fabric and may be not ssh at all), testing something, etc. In this terms I have such abstraction as "step".
Some code:
class IStep(object):
def run():
raise NotImplementedError()
And the certain steps:
class DeployStep: ...
class ValidateUSBFlash: ...
class SwitchVersionS: ...
Where I implement run method.
Then I use some "builder" class which can add steps to internal list and has a method "start" running all step one by one.
And I like this. It's loosely coupled system. It works fine in simple cases.. But sometimes some steps have to use the results from previous steps. Andnow I have problems. Before now I had internal dict in "builder" and namedit as "world" and passed it to each run() methods of steps. It worked but I disliked this.
How would you solve this problem and how would you do it? I understant thatit's more architecture specific question, not a python one.
I bet I wouldn't have asked this if I had worked with some of functional programming languages.
First of all I would like to apologize for the name of topic. I really didn't know how to name it more correctly.
I mostly develop on Python some automation scripts such as deployment (it'snot about fabric and may be not ssh at all), testing something, etc. In this terms I have such abstraction as "step".
Some code:
class IStep(object):
def run():
raise NotImplementedError()
And the certain steps:
class DeployStep: ...
class ValidateUSBFlash: ...
class SwitchVersionS: ...
Where I implement run method.
Then I use some "builder" class which can add steps to internal list and has a method "start" running all step one by one.
And I like this. It's loosely coupled system. It works fine in simple cases.. But sometimes some steps have to use the results from previous steps. Andnow I have problems. Before now I had internal dict in "builder" and namedit as "world" and passed it to each run() methods of steps. It worked but I disliked this.
How would you solve this problem and how would you do it? I understant thatit's more architecture specific question, not a python one.
I bet I wouldn't have asked this if I had worked with some of functional programming languages.
Aucun commentaire:
Enregistrer un commentaire