asham has asked for the wisdom of the Perl Monks concerning the following question:
To support user customization for flows of tasks, I am wondering following: Approach one:Issue in detail: Let say we have 4 major tasks: A, B, C, D such that following combinat +ions are considered valid: 1) A->B->C->D 2) A->C->D 3) A->B->C 4) A->D and so on. On top of that, we would like to allow users to customize the flow of +tasks as following: 1) A->myOperations->D 2) A->preTaskDoperations->D->postTaskDoperations. Currently, I have support for user flow without this customization lik +e 1) A->B->C->D 2) A->C->D 3) A->B->C 4) A->D and so on. Note: same was mentioned above earlier.
Approach two:<!--Make an xml file something like below--> <xmlFile> <action name="A" execute="true"> </action> <action name="B" execute="true"> <arguments> <arg name="endToEnd" value="true"/> </arguments> <preTasks> <!--thinking of making this as text--> $ENV{skipActions}='true'; makeAServerdown(); <!--this can be later executed with exec function--> </preTasks> <postTasks> checkBServer(); </postTasks> </action> </xmlFile>
So after having read above, could you please suggest any improvements/alternate mechanism to handle the use case? Also, are there any existing apis which support mix of xml/perl? Thanks in advance.Object Oriented approach. 1) make code file which has such customized details. (derived class) 2) provide override mechanism to end user. 3) support flow of tasks like mentioned in xml but remove perl code fr +om there. There are several alternatives to do this which maybe as si +mple as reading properties file.
Ps: Based on queries from perl monks, sharing real life example below:
let say you are in automobile factory: buildFrame->addSeats->addMechanicalParts->addDoors->paintCar->touchUp
Today let say we have following flow: 1) buildFrame->addSeats->addMechanicalParts->addDoors->paintCar->touchUp 2) buildFrame->addSeats->addMechanicalParts->paintCar->touchUp
Tomorrow, I want to expand my factory to handle following: (can be on request basis also):
new cases: 1) buildFrame->addSeats->postAddSeatsTask->addMechanicalParts->paintCar->touchUp this postAddSeatsTask maybe like replacing existing seats with leather seats. Note: only few people want it and changing whole assembly line for few people is expensive. few customers may want this and some may want something different like more leg space shorter seats. So customization is different for both and can not be predicted in advance that we provide them an API. some may want to fit couch from some company. so we may provide plug and play feature too.
I hope this gives a sense that customizations are many and with plug and play more or less things should be fine.
Above was for customization but yes tomorrow flow can change, company decides we wont paint car during production phase. but only before delivering to customer. So they remove that step and add it later changing flow of steps as below: buildFrame->addSeats->postAddSeatsTask->addMechanicalParts->touchUp->paintCar.
I hope this covers that flow needs to be flexible and steps may be added or removed as product changes.
|
|---|