In the context of sports scheduling, I have a
ViolationChecker class intialized with a
Match, whose task is to check whether placing the match in a given time-slot produces a rule violation or not. An example of its usage would be:
checker = ViolationChecker(match) match_fits_in_timeslot = checker.check(timeslot)
The main job of the scheduling process is finding a fitting time-slot for ervery match in the schedule, therefore, we will have a
ViolationChecker for each one of these matches.
In the scheduling class, we would find something along these lines:
if checker.check(timeslot): match.timeslot = timeslot match.save()
Now, the decision I need to make is where should I store those
- Should they be a member of the
Matchclass? They would be accessed just like this:
- Or should they be stored in a
ViolationCheckerdictionary in the
Schedulerclass? They would be accessed this way:
Option A is much cleaner, while Option B is a bit awkward. However, it makes more sense that the responsibility of calling the checker lies in the
Scheduler class, whose task is to, well, schedule, rather than calling it from a
Match, which is just an entity and doesn't necessarily have anything to do with the scheduling process.
How is this scenario usually tackled? Should it be a member or should a dictionary be used?