Time *not* to refactor the JobDispatcher class
The JobDispatcher has to tasks to perform: keeping track of the dispatched jobs and executing them.
So, at one point, Marc and I discussed about adding a virtual Execute(IJob job) method that would Execute the job. This way, inheritors could add tracking or exception handling.
But we realized that this solution has two drawbacks:
- There is no way ensure that inheritors of the JobDispatcher will use this virtual method.
- If the method is public, users of the JobDispatcher might think they can use when in fact we do not want to, and, if the method is protected, we will prevent inheritors to decorate other JobDispatcher.
But nothing prevents inheritors to decorate the jobs being dispatched and therefore add the behavior they want to.
If you want to have a better idea of what I am taking about, take look at Marc's MonitoredTask and imagine a JobDispatcher using it to wrap every dispatched job.