I have an Event class which holds start and end times for an event. Each Event object can have a number of associated ChildEvent objects representing each recurrence of the parent Event. Each of those classes needs to take a different action based on how they are being edited e.g.
Deleting just one Event:
Deleting an Event and all subsequent events:
Editing just one Event:
Editing an Event and all subsequent events:
At present I'm achieving this through checking for conditions and taking appropriate action but it's starting to get messy (there are other conditions with associated behaviours too). I'm curious to know how more experienced programmers would handle this (I'm using ruby). Any ideas?
Sounds like a case for the specification pattern to encapsulate your logic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With