Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
I'm creating a workflow generator where you can fill in some questions in select form dropdowns in one
, that when changed will change the text in the workflow and add pictures to a sidebar if they are relevant to the flow. I already know how to do this and it works the way that I want it to.

My issue is that I would like to know if there is an optimal way to do this. I have thousands of lines and scenarios that I am just wondering if it's fine to write all of the possibilities in Javascript like I am doing currently, or if it would be easier to write them into an XML file and read from that or something else.

What I have tried:

Currently handwriting all of the possible solutions in the JS file.
Posted

1 solution

This is an ideal candidate for a State Machine based solution. In fact a workflow is by definition a state machine. Search for some background on this topic if you're not already familar, you'll find many descriptions.

Why bother? Well you've said yourself that you have many thousands of lines of JS. If you formalise your solution into a state machine, or you may need a nested machine. e.g. Using an "outer" machine that guides through the overall workflow, with sub-machines activated when certain top level states are entered.

This approach should help to organise your your thoughts about the solution and not least to document it. Changes to the workflow are easily added once you have a generic state machine implementation.

The key features of a state machine are: (1) Define the states, these are "activities" (things that are to be done) in your workflow; (2) Define the allowed transitions (if in state "A" you can move to state "B", "C", .. "Z", and possibly also back to "A" etc); (3) Define the events that drive state transitions. In your case the completion of some work is probably an event, but perhaps an interruption such as cancellation of a task can occur which might trigger a transition into another state (such as Idle).

I don't think you should look on XML as something to adopt simply because it seems like a possibly-useful technology. Yes, XML may have a role to play, but you need to work through your design first and let the technologies used stem from that, rather than designing something with a prior assumption that you should be using this or that technique.

I've posted this as a solution which is probably a bit optimistic, however, realistically speaking I don't think your question can be answered in any more concrete terms. Good luck with it - sounds like a fun project!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900