0

I am implementing a workflow management system, where the workflow developer overloads a little process function and inherits from a Workflow class. The class offers a method named add_component in order to add a component to the workflow (a component is the execution of a software or can be more complex).

My Workflow class in order to display status needs to know what components have been added to the workflow. To do so I tried 2 things:

  1. execute the process function 2 times, the first time allow to gather all components required, the second one is for the real execution. The problem is, if the workflow developer do something else than adding components (add element in a databases, create a file) this will be done twice!
  2. parse the python code of the function to extract only the add_component lines, this works but if some components are in a if / else statement and the component should not be executed, the component apears in the monitoring!

I'm wondering if there is other solution (I thought about making my workflow being an XML or something to parse easier but this is less flexible).

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user1595929
  • 1,284
  • 3
  • 13
  • 23
  • I think this might interest you: [Halting problem](http://en.wikipedia.org/wiki/Halting_problem) – Dunno Nov 26 '13 at 16:11

1 Answers1

0

You cannot know what a program does without "executing" it (could be in some context where you mock things you don't want to be modified but it look like shooting at a moving target).

If you do a handmade parsing there will always be some issues you miss.

You should break the code in two functions :

  • a first one where the code can only add_component(s) without any side effects, but with the possibility to run real code to check the environment etc. to know which components to add.
  • a second one that can have side effects and rely on the added components.

Using an XML (or any static format) is similar except :

  • you are certain there are no side effects (don't need to rely on the programmer respecting the documentation)
  • much less flexibility but be sure you need it.
siukurnin
  • 2,862
  • 17
  • 20