|Keep It Simple, Stupid|
handling tasks and customizing flow of tasks using perlby asham (Novice)
|on Sep 29, 2013 at 12:07 UTC||Need Help??|
asham has asked for the
wisdom of the Perl Monks concerning the following question:
Hi Perl Monks, I have some existing code which carries out some special tasks. These tasks have different set of combinations available and on top of that API user (another coder/normal user) may want to customize it let say by doing some actions between consecutive tasks. I would need your suggestions to write good code to do the job. Below is an example of issue above and couple of solutions in my mind.
To support user customization for flows of tasks, I am wondering following: Approach one:
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.
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.