in reply to Flow control / case structure
and so on. Now, several of your forms may want to perform the same processing - for example, checking a form value that could be on several forms. So the decision for the new value of &mystate could depend on what the initial request was.if (&mystate eq "REGISTER") { if (&UserName eq "") { &mystate = "ERROR"; &error_code = "Missing user name"; } else { &mystate = "CHECKADDRESS"; } }
Percentive monks will see that by using a sequence of IF blocks, within one pass of the loop, the program may pass through several states in sequence - that is not a problem. That advantage of this approach is that you have broken up your processing logic into a number of discrete chunks, each doing a particular function (validating an address, doing a data base search for a list of courses, whatever), and hence becomes easier to maintain.
As well, your business logic - what is required to process a course booking, for example, is listed in the logic of chosing the state progressions. So if you need ot add some additional business logic at a later stage (oops - we forgot that we need an email address when accepting course bookings), then you can add it reasonable simply.
I apologise if the explanation is a trifle obscure - one should not try to undertake algorithm design late on a friday evening!
|
---|