hi! 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:
- Event: make the first child the parent of all other children before deleting
- ChildEvent: just delete as normal
Deleting an Event and all subsequent events:
- Event: delete all child events then delete itself
- ChildEvent: delete all future siblings then delete itself
Editing just one Event:
- Event: make the first child the parent of all other children then update
- ChildEvent: update itself as usual
Editing an Event and all subsequent events:
- Event: update all child events then update itself
- ChildEvent: update all future siblings then update itself
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?