Description
Robert Kasanicky opened BATCH-372 and commented
Currently setup of the job/step execution (figuring out whether it should be run and whether it is being restarted) is part of the execute() method rather than being dealt with separately. This has some bad consequences - even when we create a fresh job instance, both job and step investigate their execution counts and last executions. It doesn't make sense as it is clear execution count must be zero and there is no last execution. Assuming a job instance is usually executed successfully and restart is an exceptional scenario makes the current state look even more awkward.
I imagine the basic execution flow should be something like:
if (findJobInstance(job, params) == null) {
createJobInstance()
setupVanillaExecution()
}
else {
restoreFromLastExecution()
}
execute() //no dealing with past here anymore, just straightforward execution
rather than current:
1.findOrCreateJobInstance(..)
2.execute(..) // checking what scenario I'm in all the time
The proposed approach clearly points finger at the DDD-hostile findOrCreateJobInstance(..) method which should be broken into two, but also moves towards removing lastExecution and executionCount properties from JobInstance as they become relevant only in the narrow context of restoreFromLastExecution().
Issue Links: