The Importance of Taking Breaks
I just added interval splits to Running Track, and vastly improved the map view too. I started working on both several months ago, but after struggling to get them working how I wanted, I got frustrated and left them alone for a long time. Yesterday, I decided to go back and look again, and both were done in a matter of hours.
Splits, in particular, were awkward to calculate. However, a couple of weeks ago I added logic to calculate your best time for a given distance. After spending time working with lower-level run sample data, it became really easy to see how I could use a similar approach to break a run up into chunks and calculate split times.
The run map has been bothering me since I first started working on it, over a year ago, as the scaling on it was terrible. Back then, I found it really awkward to find a nice way to translate the coordinates of a run into something that MapKit could use to present the route. So the route was tiny in the middle of the map, and you had to zoom to be able to get any value from it. But when I went back to the problem, it felt like the solution was staring me in the face. And again, it was work I'd done in another area that just helped to clarify my thinking.
It’s funny how easy the things that feel difficult can turn out to be, when you just take a break from the problem and go back to them. It's important to recognise when you're hitting a wall with a problem, and to go and find something else to work on instead, or even something completely different to do. Sometimes you'll learn something new that makes the original problem much simpler. Sometimes you'll just see something from a different perspective, because you've stopped focusing so intently on one part of the issue. Most of my problem-solving happens when I'm running or cleaning, because my mind is in a completely different place, then it drifts back to what's been bothering me.
PS: A bonus fix yesterday (I had one of those really productive days that probably comes along once a month) was getting heart rate calculations down from 10 seconds to 0.1 seconds, because I was needlessly sorting them. I only thought to check the query because I accidentally introduced a similar problem elsewhere in the app, realised what it was straight away, and wondered where else I'd made the same mistake. I’d previously just accepted that querying heart rate data was slow. As well as a good example of how answers can come to you when you're not actively looking for them, it's also a good lesson to keep questioning things that you aren't happy with.
Published on 19 May 2020