Coding a batch process with numerous steps that can succeed or fail, while keeping control in calling program whether the whole process has succeeded and, if not, knowing the reason why, can end up with an unreadable program because of the multiple
if ... endif or
do case ... case ... endcase indented blocks.
if m.success... endif ends up with unreadable nested indentations and makes it difficult to change the tasks order:
if !m.success... endif repeats code and adds multiple returns, but makes task order changes easier:
do case ... case ... endcase requires sub-procedures and is still uselessly verbose and somewhat difficult to understand as it relies on negations:
We found a convenient way to make program more readable by:
- moving all concrete work to sub-procedures using a standard scheme for naming, parameters and returned value
- chaining the calls to sub-procedures into a single logical expression
Let’s say main procedure is
First create one procedure per step:
Then create the main procedure:
Very convenient is the ability to change the tasks’ order by just swapping 2 lines.
do_task_stepX() could be further broken into
Watch FoxInCloud Marketing Videos :: Watch FoxInCloud Technical Videos :: Stay tuned on FoxInCloud Roadmap :: Learn how to use FoxInCloud :: Download FoxInCloud Adaptation Assistant for free :: Download FoxInCloud Web Application Studio for free