Page 1 of 1

Multi-Page Wizard ... Proposed Structure

Posted: Sun Feb 10, 2008 3:51 pm
by jeffrydell
Looking for your thoughts as I've pretty much given up on using ZervWizard for my project. I can't see a reasonable way to extend that class in such a way that I'd be able to add, subtract, or change Steps on the fly. It is what it is, and if you don't know your steps "going in", you're just not going to be able to adapt properly. At least that's my assessment after 2 weeks of messing with it.

So, I'm hoping y'all will make suggestions and offer comments on two things.

1) Is there another class out there (or bundle of classes) which might help me effectively manage a multi-form application for taking reservations? It needs to be adaptable as not every form is required in every reservation process, and some reservations require that a group of steps get repeated. Sometimes that group of steps must be repeated 3 or more times.

2) I have laid out what I believe would be a structure for this application, but I'd like those of you with OOP experience to take a look and see if I'm anticipating all I need to do, skipping things or breaking things down "too tiny".

Please note - I've been learning & writing php procedures for a while now, but I'm just getting my feet wet in the world of OOP, so don't laugh too hard!

AT THE CORE would be a Step Handler class.
Call a step-specific Preparation routine which would
Determine whether data needs to be / can be retrieved from an existing table
If data can / shoud be retrieved - populate the step Array from the step table(s)
Stuff the step Array with blanks for any field which does not exist so it matches the table structure

Include the Form

Upon Form completion (submit button), populate the Step Array with POST values
Call the appropriate validation routine for that step
Return T if data is valid, F if the step must be re-done to correct missing or invalid inputs

Extending the Step Handler class would be a step management class
Retrieve Requested Step Info from a MySQL table including form file name, what step-specific (& state-specific) preparation & processing routines would be used, the next step, step Array name, Table(s) in the MySQL database which may be related to the step.

Determine whether requested step can be allowed based on whether necessary data is available
If not allowable, determine appropriate step based on data currently available - then reroute to correct step
If necessary, start over requesting appropriate step

Call the step

Upon successful completion of the step, determine the next step based on the MySQL 'routing' table and state of the class

If the user hits their 'Back' button, route the user back to the previous step.

The script which calls these classes would check for valid access prior to instantiating the classes, and commit data to the MySQL database, send out necessary e-mails and hand the payment info off to the online payment processing service - thus completing the cycle.

Obviously all that above is a brief overview with many details within each step & each class. Any thoughts on whether this is comprehensive enough to build the framework from, or wheter there are other issues to be considered / included at this point?

Anywhere I can read up on considerations before I get started putting some meat on these bones?

As always, thanks for your ideas!

Re: Multi-Page Wizard ... Proposed Structure

Posted: Sun Feb 10, 2008 5:01 pm
by Christopher
I think we discussed this previously in a separate thread. Ultimately this is an Application Controller which is a difficult thing to get right (as you have found). If you can find it, read the paper Objects and the Web by Knight & Dai. It is what Fowler references in the PoEAA for this pattern. I would recommend building something like you suggest, keeping it as simple and clear (and documented) as you can. Using some reasonable conventions can greatly simplify the problem.

If you want to go the full state machine route, I have an implementation that might be interesting for you to look at and maybe even use. I don't remember if I still have the session based rules to do wizards though.

Re: Multi-Page Wizard ... Proposed Structure

Posted: Sun Feb 10, 2008 5:23 pm
by jeffrydell
I'll go looking for that article. Are you the same Arborint that was posting on a similar topic in the Sitepoint forum a year or so ago?

Re: Multi-Page Wizard ... Proposed Structure

Posted: Sun Feb 10, 2008 6:18 pm
by Christopher
Probably. Application Controllers are not exactly a hot topic. That ZervWizard thingy caught my eye interest recently too, but unfortunately its "each state is a method" design it is not modular enough to make very flexible. The whole "controller of controllers" aspect to wizards it what makes your brain hurt. ;)

Re: Multi-Page Wizard ... Proposed Structure

Posted: Sun Feb 10, 2008 6:40 pm
by jeffrydell
Indeed. Not exactly an 'elegant' introduction in to OOP.

I PURCHASED the article and am working my way through it now. Thanks for the lead.