O'Reilly logo

Design – Build – Run: Applied Practices and Principles for Production-Ready Software Development by Dave Ingram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required