My Current Project
Anne and I have a home gym consisting of:
- a Bowflex machine
- an elliptical trainer
- various hand weights
- an exercise ball
- a DVD player and TV (very important, as exercising is boring as hell)
Until now, Anne kept track of her workout progress on scraps of paper, while I used the vast wasteland that is my brain (What was I up to on this exercise? 50 lbs?). So, I decided to write an application to do this for us.
Since we both have iPhones, I thought it would be useful to write a web application for it since we can keep it in our pocket or even on the couch next to the Bowflex where it's convenient to enter data. Besides, it would be a good way to learn web programming, especially Ajax.
I forged down into the den/gym, iPhone in hand, to attempt to record my first workout. All was going well: I was able to easily enter data, add more exercises, etc. As always happens, though, I noticed several improvements that could be made. Switching over to the iPhone mail application, I started an email to myself listing these ideas.
Then I switched back to the web browser and learned my first big lesson about web development for the iPhone: when the iPhone senses it is getting low on RAM, the first thing it gets rid of is web pages, figuring it will just save the URL and reload the page. This does not work so well when you have an entire page full of data entered by the user. Poof! Gone.
I'm still working on a solution to that (which involves periodically sending the current data up to the server, which it stuffs into the database in XML format in case it needs to retrieve it later), but in the meantime I know not to switch to other apps (or even other memory-hungry web pages) while doing a workout.
A few tests later, I learned my second big lesson: Safari is much stricter than Firefox with regard to the DOM.
In this case, I was testing the ability to remove an exercise from the page (not sure why you would want to do this, but I put it in there anyway). As it turns out, I had used the same "id" attribute for the <div> I was removing as for an element within that <div>. Firefox happily removed the intended <div>, but Safari (both on the Mac and on the iPhone) puked and did all sorts of strange things.
Sure, I had a corrupted DOM, but it wasn't like it was ambiguous: I was removing a particular child <div> that had a particular <id>. It shouldn't have been looking at the <div>'s child nodes.
The difficult thing in that situation is that Safari's debugging tools are not quite as good as Firebug, so it's harder to trace these problems through when they only happen on Safari.
Overall it's been really fun learning all these technologies, and architecting and developing my own little app, that is actually quite useful. Not to mention it relieves some of the boredom of working out.