Day 79: Off by one
While implementing group streaks today, I discovered that my implementation for individual streaks is wrong. None of my friends using it have mentioned it to me because it’s not obvious that it’s wrong until you think about it for quite a while.
Let’s start with what a streak is. Imagine that you’re a lazy, dirty boy and you want to build the habit of taking a shower every day. The first day you take a shower, you have a streak of 1 day. If you do it again the second day, now you have a 2-day streak.
But what does it mean to have a streak when you’re refraining from doing something? In Intention, success is defined by not going over your browsing limit. So if you succeed in not going over your limit, your streak should increase by one.
Here’s how the current implementation of streaks works:
- Upon installation, Intention starts you off with a streak of 1
- If you go over your limit, your streak resets to 0
- At midnight, your streak increases by 1
If you can already spot why this is problematic, give yourself a pat on the back because you are clearly sharper than this tool (yes, me).
The reason why I didn’t think twice about this and why I suspect no one has mentioned it to me is that it works decently well despite being technically incorrect. It also has a nice benefit in that it starts you off on a positive note and there’s something to lose if you go over your limit.
So why is this wrong?
It’s a bit tricky because we’re dealing with the absence of an undesirable act (not going over your limit) rather than the presence of a desirable act (taking a shower), but upon installation, you haven’t spent enough time staying under your limit so the streak should be 0, not 1.
The other bug is that the streak should only increase if you’ve stayed under your limit the previous day. Imagine someone breaks their limit and has their streak reset to 0. When midnight hits, their streak should remain at 0 (they haven’t succeeded in staying under their limit), not increase to 1.
These details may seem really minor, but it bothered me because it’s inconsistent with how group streaks have to work. The main challenge with group streaks is that members of a group might be in different time zones. With an individual user, I can increase their streak if at some time (e.g. midnight), they’re still under their limit. But what happens when everyone’s midnight is different?
I wanted everyone in a group to see the same streak number, so the solution I decided to go with was to increase the streak if 24 hours have passed since the last time the streak was reset (either upon group creation or someone breaking the streak). It wouldn’t make sense for streaks to start at 1 (24 hours have not passed) so streaks would have to start at 0. And that’s how I realized that my individual streak logic was flawed.
Anyway, this post was me just trying to think through this stuff out loud and if you’ve read this far, I am terribly sorry because this is some really bad reading material. It’s possible that none of the above makes sense or that my reasoning is flawed but at this point, I’m too tired to be able to tell so I’ll think about this again tomorrow.
I need to start writing in the mornings again instead of putting off R2R posts until I’m half brain-dead and vomiting onto the page.