Refactoring – Single Responsibility Principle (SRP) applied to JobMan

The MainJob Class stores the data regarding a Job but also issues subjob numbers. Similarly the JobDatabase issues the MainJob Numbers. The Job numbers follow a particular scheme. So the scheme could be injected into the JobDatabase removing the responsibility from the MainJob class.  This will also impact on JobComparator class which will also have to move to a dependency injection.

The trick will be ensuring the proper comparator with the numbering scheme, or at least instances where the comparitor uses the numbering scheme. The JobNumberingInterface could specify its own comparitor via injection with the method: public String getComparator().

Leave a Reply

Your email address will not be published. Required fields are marked *