16.4. Generic Jobs and Generic Functionality

Generic and reusable functionality is pretty much a key feature of an extensible design. You can see from the patterns already discussed that you need only a single execution shell per invocation method. As it stands right now, you need a batch manager for each "type" of job. This is because the manager is responsible for the specific "work item selection." You could even make this functionality totally generic and simply delegate this task down to the batch processor, as shown in Figure 16-17.

Figure 16.17. Figure 16-17

The processor would have already been called during initialization with all the parameters, and so forth, so it would already have everything it needed to obtain the records. It could either return the number of items back to the manager, or perhaps even a collection of items. It really depends on the threading model chosen and what information each processing thread required. Of course, the manager would then need to pass the items to process to the processor thread, which could require a certain level of interpretation.

Using this type of approach helps to implement a completely generic manager and there's no reason why we couldn't implement this. It would reduce the overhead in introducing new jobs, reduce development timescales, and reduce the number of moving parts in the solution. Given all the implementation ...

Get Design – Build – Run: Applied Practices and Principles for Production-Ready Software Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.