Open jakmaz opened 6 months ago
I think this problem implementation is beyond my skills just yet, thanks for reviewing it
@jakmaz I can guide you through it, if you want! You have 90% of the solution there, it just needs some small tweaks
Okay! I suppose I get the point of adding the id field more now. I also thought of another solution, that is adding the abstract method addToScheduler(scheduler ToadScheduler)
to the Job class and implementing it in each Job type to call the correct scheduler method. Then there would be no need to use any identifiers, but it could be a bit more messy. What do you think?
Description:
This pull request simplifies the
ToadScheduler
by introducing a unifiedaddJob
method for job addition, deprecating the specific methods likeaddIntervalJob
andaddCronJob
.Rationale:
I chose this simple, single-method design over a polymorphic approach to maintain ease of use and understandability. The alternative considered was a more polymorphic design, where each job type would know how to add itself to the scheduler:
Instead, I used a straightforward approach where the
addJob
method internally determines the job type and delegates to the appropriate method:This approach would follow the Open/Closed Principle more closely but was not adopted due to the stability and limited extension expected in our job types.
Impact:
The update simplifies adding jobs to the scheduler, making the codebase easier to maintain and understand while still allowing for internal specialization for different job types.