3 ms·
I was working on a calendaring system. We supported recurring events, and each event could also have a piece of equipment associated with it (one or more). Even
by mooreds 8y ago
I was working on a calendaring system. We supported recurring events, and each event could also have a piece of equipment associated with it (one or more). Events could also be changed, either the current event or this and every event. Event start/stop times were stored in UTC, but the event was displayed in the users timezone, and could cross daylight savings time boundaries. This was done with a mix of javascript on the front end and ruby on the backend.
When first implemented, the equipment was reserved for the entire time of the event. A feature request came in to allow for partial reservations of equipment (we want to reserve space A for four hours, but equipment B for only the last hour and equipment C for the first two hours).
Solving it on initial event creation was pretty easy. The UX was difficult. But handling updates, especially across recurring events, in a way that was maintainable and correct was the hardest technical work I've done. I wrote a lot of tests.
The difficulty was compounded by the fact that this was a startup and I had no technical peers to discuss the issue with. The code implementing the work wasn't the cleanest either. I could have reached out to friends, but they wouldn't have had the understanding of the issue.
- iambateman 8y agoMy first big project was working with a back-end developer on a custom implementation of a calendaring system. It was one massive several-month nightmare. Totally relate...
- whack 8y agoHow did you handle the database storage for recurring events? Did you have just one entry that represents the recurring event as a abstract whole, or a database entry for each instance of the recurring event? The former seems "better", but you also run into a whole lot of complications: 1) The user can delete specific instances of a recurring event. Eg: delete the event for thanksgiving Thursday but leave it intact for all other Thursdays 2) The user can make instance-specific edits. Eg: edit the event description with custom meeting-notes that's specific to that week's instance 3) The user can invite/dis-invite people for specific instances. Eg: invite Dave only for the event this Thursday, but not for the following weeks' Creating a database entry for each instance avoids the above complications, but comes with its own drawbacks: if a user creates a recurring event with no end-date, you have to populate a large number of instances, all the way until some arbitrary MAX_DATE. I was asked this question in an interview once and I recommended the latter option as the lesser evil, and the interviewer was visibly displeased with my recommendation. I'm wondering what the better solution would be.
- gerhardi 8y agoSome very quick thoughts.. Have something to resemble the event series as a single instance - then have 1...n relation to actual occurrences for occasions when there has been a change, added notes or cancellation. These should be created when the change/added notes/etc. are made.
- thecatspaw 8y agoI would have one meta event, and if you modify it, you implicitly clone it and modify that clone
- was_boring 8y agoI have worked with recurring events, and the answer that I've seen is generally both. You have one record which is the "template" and then populate the database out with specific instances to some arbitrary date. Every so often then run a cron to populate further and further out.
- mooreds 8y agoThat's pretty much what I did, but the original record wasn't stored in the DB, just the specific instances. Our use case was such that folks were moving around events periodically (it was a scheduling app), so we rarely had anyone "run off the end" of their repeated events.
- mooreds 8y agoI went with the latter. We limited the total number of events to something like 5 or 10 years to avoid it [edit: the max age problem]. The only real issues that came up from that approach were: * UX was hard when people want to change individual events that are also part of a recurring event (who wins) * daylight savings time is an issue when you store datetime in UTC (you need to shift the UTC value in Nov vs in June to have it be the same "8am every Friday" event) * saving a change across all of a large number of events created a large, slow transaction that caused slow responses (in some cases triggering heroku timeouts) I was lucky that we didn't need to implement inviting guests, as that wasn't needed. There were times when I wish I'd implemented the RFC standard: https://www.ietf.org/rfc/rfc2445.txt https://www.ietf.org/rfc/rfc2445.txt but never got to that. (We also evaluated just building on top of Google Calendar, but I was worried about building on top of an API that we weren't paying for, and there was the issue of tying in child equipment events.)
- owyn 8y agoThe hardest thing I ever worked on was a calendaring system for scheduling ads on/off. The UI was great, but I just told them "oh, send me a cron format string for scheduling". It was easy for them to do, but very hard to handle on the back end. Cron format strings aren't fun to reverse engineer. Why did I do that? File under "things programmers assume about time". It kept doing "weird" things from the user perspective and I ended up writing more tests for that subsystem than anything else I've ever done.
- shaklee3 8y agoIf it makes you feel any better, there is a large section of this book dedicated to a team struggling to implement recurring events properly: https://www.amazon.com/Dreaming-Code-Programmers-Transcendent-Software/dp/1400082471 https://www.amazon.com/Dreaming-Code-Programmers-Transcenden... Great read, and shows how difficult it was and is to compete with office.