« Productivity is the name of the game | Main | AOP and polymorphism again »

Wizard task revisited

My original concept of the wizard task children was a set of items that would be evaluated in forward or reverse order based on what the user said at the prompt elements, but based on what I have coded it will not quite work. Consider pseudocode of my first approach in my test file...

sidebar image A
prompt 1
sidebar image B
prompt 2
sidebar hide
prompt 3

This would describe three wizard pages, the first with sidebar image A, the second with sidebar image B, and the third with no sidebar. You would expect that if you go to page 3 and go back to page 2 that you would see sidebar image B, well in the simple algorithm I coded you would stop at prompt 2 but no sidebar image would be produced. Going backwards from prompt 3 you would encounter sidebar hide and then get to prompt 2. Back again would bring you to sidebar image B and then to prompt 1. But sidebar image A would never be seen once passed. This can be coded around...

sidebar image A
prompt 1
sidebar image A
sidebar image B
prompt 2
sidebar image B
sidebar hide
prompt 3

But this sends a shiver down my spine as being (a) ugly and (b) brittle due to code duplication. Clearly just going forwards and backwards will never work, and I never realized that because how often do you write code that is intended to be run backwards as well as forwards? Even when you kick out of a transaction the code is read forward but you just unlock in reverse order you gained the locks. It's like a stack, going back down in it is still coded in a forward fashion.

So here is my current thinking (but the names of the elements may change, suggestions welcome):

<wizard> : wizChildren
<step> : wizChildren
wizChildren : (<step> | <prompt> | <do> | <undo> | <doDisplay> | <undoDisplay>)+
<do>: ant tasks
<undo> : ant tasks
<prompt> : promptChildren
<doPrompt> : promptChildren
<undoPrompt> : promptChildren
promptChildren : <sidebar>?, <header>?, <centerPane>
<sidebar> : splashChildren
<header> : splashChildren
<centerPane> : splashChildren, <formPage>

Rather than having the sidebar and panel be direct children of the wizard task, they are direct children of the prompt element, or the two new ones doDisplay undoDisplay. This makes what should be a "page" more atomic, and also separates the page from the transition code between those pages. The doDisplay and undoDisplay elements allows for the wizard page to be changed during execution of long tasks without soliciting "must respond" interaction. There are still some nuances for cancelable tasks and ordering, but those don't look offensively ugly like the first approach. Given this re-design the pseudo code would look like...

prompt 1
    sidebar image A
prompt 2
    sidebar image B
prompt 3
    sidebar hide

It doesn't look too different from the initial but this is a simple example. A more complex example would have betrayed just how bad my first look (it would border on un-readable). Hopefully it would also show just how much better this new approach seems too me right now, bit I haven't coded any really complex stuff.

On a different note I have decided on an initial goal and litmus test for deciding when the various parts of Inst.ant are soup: Can it install Tomcat? For inform.ant it will be can it gather all the install data for Tomcat. For propell.ant it will be when it has the tasks to do all of the nifty platform specific stuff like application menu items, service/daemon instillation, proposal of good default locations on Windows, Linux (ReadHat 7.3), and Mac OS X. For compon.ant/redund.ant it will be single-jar instillation of the precious. And for dist.ant it will be native executables for the same, although that task looks kind of distant.

About

This page contains a single entry from the blog posted on October 21, 2002 8:00 AM.

The previous post in this blog was Productivity is the name of the game.

The next post in this blog is AOP and polymorphism again.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33