An App In Under Five Hours
The other day on my long train ride from my home and college, I had an idea. I was sick of my fear of missing my stop whenever I was in a train (or even worse, on a bus, because Irish towns look identical), and I thought that it would be handy to have an app that would alarm you when you were near your destination. Then, I proceeded to make it (it’s here if you want to skip reading the post – switch off auto-lock on your phone first).
Now, I had a way of getting the user’s approximate latitude and longitude. Next, I needed a way to show this to the user. It took me about thirty microseconds before I hit up the Google Maps API page. The Maps API is a real joy to work with. It takes absolutely no effort to get started with it, and the documentation (as all of Google’s documentation) is the stuff of legends. So, now I had my user’s location showing up on a map. I had (well, in reality I only just implemented this ten minutes ago, but it took no time at all) my user inputting his target destination.Next I needed a way to get the distance from my user to his destination. A quick trip to the Google, and by extension to Movable Type got me not only the formula, but the code! It was a matter of plugging in the right numbers in the right places, and presto, distance.
Finally came the actual alarm implementation. This ended up being a whole eleven lines of code – and that’s being generous with my brackets. (However, the sound implementation did take me some time, as I had to invent a new way to get around iPhone Safari’s lack of autoloading sounds, which I detailed in this post)
My biggest problem, and the app’s biggest flaw, is that on the iPhone, Safari won’t run in the background, either while locked or using other apps. This means that in order to use the alarm, you need to switch off auto-locking in the settings – and turn down brightness while you’re here. In my quick-and-dirty test, my battery went down seven percent over thirty minutes, though I left brightness at max and wifi on. Without those, you might be looking at four percent over that time. That’s not heart-stoppingly awful, it’s just not great. So, if you want to use the app, remember to switch off auto-lock.
Wham, bam, thank you ma’am
So there you have it. While the fact remains that it’s uglier than Cthulthu himself, and there’s absolutely no configurability other than moving your destination (the alarm will ring when you’re five kilometres or less away from your destination), the core implementation and virtually all of the code was written in under five hours, in two nights, fuelled by several hundred cups of tea.
The moral of the story
The moral of the story is this: stop thinking that “someone should make this” and just make it yourself. I did this in two nights in between an exam and a project deadline. It took virtually no time and does exactly what I need it to do. Most importantly, I stopped thinking about design patterns and heap memory and went completely nuts with my code. Nobody’s going to grade me on this, nor am I going to get fired. When I thought “Damn, I need a global variable here” I didn’t spend hours re-architecting the code to get around it. I just (hold on to your hats) made one. A piano didn’t drop from the heavens and the sky didn’t fall.
If you want to use this app, go for it! It’s live right here. It’s a long link, I’ll move it sooner or later, but I’ll also redirect from that one so feel free to bookmark it.
I offer absolutely nothing in the way of guarantees that it’ll work, but it should. Tap on your destination, leave the page open (and as explained above, switch off auto-lock on your iPhone), and fall asleep at will.