Making departure lists faster

For the last few weeks I’ve been working on how the app computes the departures from a particular stop. This is the new version that works on android, iOS, and the web version, whereas the current version only works on android.

In addition to working on more platforms the new version is going to be much faster – really lightning fast – and solve some problems with the old version.

The worst problem was that the old way to compute departures worked day-by-day and considered all possible departures every day. This means that even if it’s Tuesday, for instance, it would also consider departures that only occur on Sundays, but just not show them because they don’t run on Tuesdays. At the end of each day it would go on to the next day and then consider all departures all over again. For a departure that runs only on Sundays the departure computation would go: does it run on a Tuesday, no, how about Wednesday, no, what about Thursday, no, Friday then, no, Saturday?, no, Sunday, yes! Now imagine a stop that only have departures in the summer – a ferry for instance – and it’s two months until summer. In that case we have to check all possible departures every day for two months until we meet the first one that actually runs. This approach seemed like a good idea but turned out not to work too well in practice.

In the new version it’s different. Instead of stepping day by day I step departure to departure, so if it’s Tuesday and the next departure is on a Sunday I’ll skip right ahead to Sunday immediately without even considering the days in between.

That’s very technical of course and while it does have an impact on what it’s like to use the app, it may seem like a lot of effort for not that much. And in a sense it is, it’s been a long time I’ve worked on this with no visible impact on the app. As a user of the app it looks like nothing at all is happening. That’s a problem so I’ve decided, in the future, I’ll make an effort to not to disappear into the machine room for long stretches but to spend at least some time making visible changes to the app. It’s not like there aren’t things that need fixing, I just decided not to focus on them. I’ll try not to do that next time.