Friday, March 6, 2015

Changes 3/6/15 - Small Stuff

Today was another snow day, so I didn't do much.  One thing I did do was try to clean up some code we had written a couple days ago.  For retrieving book information from Librivox servers, we are using JSON because it's very easy to work with in Javascript and Librivox supports it.  I wrote a #getJSON(url, callback) function to do this.  However, in order to parse Librivox's mp3 urls for streaming the audiobooks directly instead of downloading them, we are accessing an RSS feed, which is in the xml format.  We then ended up with this method, (a direct duplication of the getJSON method with two lines difference) which is not good at all!
I got around to refactoring it today, and the result is definitely better, but it's not perfect. For one, it uses the magic strings 'json' and 'xml' to account for the slight differences in the methods. Additionally, the 'xml' string isn't even referenced anywhere in #getDataFromUrl because the XMLHTTPRequest class assumes xml by default, which would be pretty misleading to someone who isn't familiar with our code.  However, I don't want to focus all my attention on making this relatively insignificant thing perfect, because we have bigger fish to fry.

The code is getting pretty messy, and our app has a lot of functionality already (Finn has been adding tons of features!), but the app also a lot of bugs that might take a while to figure out.  We have a few problems stemming from jQuery Mobile's page refresh behavior that will probably require a much better understanding of the library than what we have currently, so even "simple" fixes will probably end up taking a lot of effort.

Also, thanks to Sam's blog, I'm now using the <code> tag instead of my <span style='code'>, which is way less typing for me considering how often I reference code concepts!

1 comment:

  1. I am delighted by the partnership you and Finn are developing! Thanks to the fantastic mentoring that you've received by working with Kevin, you are now the much more mature developer of the pair, so it probably a good division of labor to have Finn solve problem in the rough first and then have you refactor them using the best practices that Kevin taught you. Before sure to "share the love" you received from Kevin with Finn, so he benefits from your wisdom as well.

    And yes, <code> is a semantic element and as such much to be preferred to <span ...>.

    ReplyDelete