Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design question: How would you design a recurring event system? [closed]

Tags:

calendar

If you were tasked to build an event scheduling system that supported recurring events, how would you do it? How do you handle when an recurring event is removed? How could you see when the future events will happen?

i.e. When creating an event, you could pick "repeating daily" (or weekly, yearly, etc).

One design per response please. I'm used to Ruby/Rails, but use whatever you want to express the design.

I was asked this at an interview, and couldn't come up with a really good response that I liked.

Note: was already asked/answered here. But I was hoping to get some more practical details, as detailed below:

  • If it was necessary to be able to comment or otherwise add data to just one instance of the recurring event, how would that work?
  • How would event changes and deletions work?
  • How do you calculate when future events happen?
like image 605
Joe Van Dyk Avatar asked Sep 23 '08 20:09

Joe Van Dyk


People also ask

How do I create a recurring event in Salesforce?

In Salesforce Classic, from Setup, enter Activity Settings in the Quick Find box, then select Enable Creation of Recurring Events. If you disable this setting, users can still edit the interval of an existing event series, but they can't create a new series.

What is a recurring event?

A recurring event is an event that happens more than once, on a repeating schedule. When a repeating event is turned into individual event instances with individual dates, it is called “expanding” the event.

What is the regular procedure and standard which is used for recurring events and activities?

An SOP is a policy and procedure document which describes the regular recurring activities appropriate to quality operations. Consistency is the goal or purpose of an SOP, to carry out all operations correctly and always in the same manner.


2 Answers

I started by implementing some temporal expression as outlined by Martin Fowler. This takes care of figuring out when a scheduled item should actually occur. It is a very elegant way of doing it. What I ended up with was just a build up on what is in the article.

The next problem was figuring out how in the world to store the expressions. The other issue is when you read out the expression, how do those fit into a not so dynamic user interface? There was talk of just serializing the expressions into a BLOB, but it would be difficult to walk the expression tree to know what was meant by it.

The solution (in my case) is to store parameters that fit the limited number of cases the User Interface will support, and from there, use that information to generate the Temporal Expressions on the fly (could serialize when created for optimization). So, the Schedule class ends up having several parameters like offset, start date, end date, day of week, and so on... and from that you can generate the Temporal Expressions to do the hard work.

As for having instances of the tasks, there is a 'service' that generates tasks for N days. Since this is an integration to an existing system and all instances are needed, this makes sense. However, an API like this can easily be used to project the recurrences without storing all instances.

like image 155
oglester Avatar answered Sep 18 '22 07:09

oglester


I've had to do this before when I was managing the database end of the project. I requested that each event be stored as separate events. This allows you to remove just one occurrence or you could move a span. It's a lot easier to remove multiples than to try and modify a single occurrence and turn it into two. We were then able to make another table which simply had a recurrenceID which contained the information of the recurrence.

like image 29
Joe Phillips Avatar answered Sep 18 '22 07:09

Joe Phillips