Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
There's more than one way to do things
 
PerlMonks  

Re: handling tasks and customizing flow of tasks using perl

by Laurent_R (Priest)
on Sep 29, 2013 at 17:24 UTC ( #1056243=note: print w/ replies, xml ) Need Help??


in reply to handling tasks and customizing flow of tasks using perl

I certainly would not use XML for that. XML is useful for things like communications between different systems or storing some configuration into a file on disk, it is really unpractical as an internal data structure.

You probably want to build a graph, which could be possibly a hash of arrays, in which the array contains all possible successor nodes to the hash key node. Or you could build a list of possible complete paths from a given node.

Your description:

1) A->B->C->D 2) A->C->D 3) A->B->C 4) A->D

is not completely sufficient to figure out the paths that are allowed. Suppose that I am on node B: does that mean that we can go to node C irrespective of what happened before (in which case paths 1 and 3 seem to be redundant), or that I am allowed to go to C only if I was on A before getting to B (so that I can't go anywhere if I am on node B but not coming from A)? Determining the best modeling for your application behavior depends on an answer to such questions.


Comment on Re: handling tasks and customizing flow of tasks using perl
Download Code
Re^2: handling tasks and customizing flow of tasks using perl
by asham (Novice) on Sep 29, 2013 at 18:28 UTC
    Hi Laurent, Thanks a lot for looking into this.

    Yes true xml are not used for such code mix but it would be kind of configuration file only right? as it holds details related to tasks. exampple: should a task be executed or not and if yes than with what configuration parameters. The only extra thing I was thinking of adding was the pre/post tasks which may vary for some users. (also idea of this post is to come up with some good design to handle the use case.)

    Regarding the building graph/hash suggested by you, I had considered that but I was not convinced with the idea because doing that means I am kind of fixing the flow of tasks. Any changes in future require update of code rather than just a tiny update in xml/properties file which can be even exposed to user. (i generally prefer xml/properties file compared to such code updates because of more flexibility and ease of use. As end user may not know the code and can just update the xml file to change/control the flow.)

    Just to let you know that mixing xml/perl is not the best design and that's why I am looking for inputs here. I wanted to check if people were using it or apis are for this. (note: jsp/jsf mix html and java. so thought something on those lines.)

    Regarding paths: 1) A->B->C->D 2) A->C->D 3) A->B->C 4) A->D

    These are just for example, you can check the xml file shared in my first post. note its rough design and any such redundancies will be handled when we actually finalize an approach.

    regarding the details requested by you. I am updating original question with a real life example. Please check, hope it helps in understanding the case more.

      Hmm,

      there are many aspects to be taken into account.

      I was writing last week a program template aimed at some other IT persons. The idea was to give them the (quite complicated and thoroughly tested) algorithm, and let them construct the input data, which could be summarized as follows:

      ('table1' => { 'index_fields' => [0, 1, 2], 'ignored_fields' => [6]}, 'table2' => { 'index_fields' => [2], 'ignored_fields' => [4, 7]}, )

      It is not too complicated to give IT persons instructions on how to fill the next records in this structure to achieve the desired result.

      But if your user has no IT background, this might not be workable.

      I still don't think that asking them to fill an XML structure is the right idea. Asking your users to write a config file such as:

      1. A -> B -> D

      is clearer for your user (so long as you explained the details) and actually easier for you to parse.

        Hi Laurent, My apologies for the late reply. Have been busy with work.

        Thanks for your reply.Regarding your reply,yes true asking users to write config file is easy. but I guess we are again missing the point.

        Idea is to come up with some design which allows customization of code and still allows to control basic flow of tasks. Till now the suggestions cover following: 1) vsespb's suggestion, covered use of known customizations. 2) your suggestion, covers control of flow and tasks.

        Also I gave it another thought and wondered if providing a template to even an inexperienced user something like following should be kind of easy to understand right?

        <xmlFile> <action name="A" execute="true" /> <action name="B" execute="true" /> </xmlFile>

        I understand its xml file. But normal user simply need to switch true to false to control flow or change order of elements (example: putting B before A) to change flow while experienced user can make use of customization tasks available. The only thing tempting me to use xml is the schema file/validations/child elements/structure offered by it which can help me mix complex and simple tasks at the same place.

        Anyway will wait a bit more for inputs before I go with any implementation.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056243]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-04-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls