Monday, March 16, 2015

Refactoring, and Exploration Into the LibriFox Android App

Today I worked with Alex a bit on refactoring, which I had eventually planned on doing - essentially, the code we currently have works, but it's a mess, and it's starting to get to the point where it's much harder than it should be to write code, simply because of how scrambled our code is.

As a result, today we worked on some minor refactoring. Even in an hour or so, only a few lines were changed, and a lot of code was broken - but the result was amazing. We must have removed over 30 lines of useless code (and keep in mind, our app is only around 300 lines of JavaScript and a few hundred lines of HTML) from our app.js. A few minor methods, notably these Chapter and Book methods below, have changed the entire way our app works for the better.


Eliminating localStorage overuse was one of the first things we came to. Alex has changed all basic localStorage access into Objects, which I had never thought of doing [since I'm still very new to JavaScript]. These Objects not only save lots of space in the code, but also make access of variables much easier.

Instead of having something like this:
We have something like this:
You can already see the incredible amount of time and space saved by using these methods, not to mention how much easier it is to add, modify, or remove code!

We will also start refactoring repeated code in our audio handlers, and create a multiclass implementation soon.

Later on this week, after some refactoring, I might look at the LibriVox app for Android. I want to make sure our app is refactored more before we start looking into adding new features!

EDIT: I also did some research about the Firefox Marketplace. Our app should be reviewed soon! In my research, I found that they allow something called "App Preloading". You can read about it here. Basically, it allows developers to submit an app to be included with the phone by default. I think later on in development, this app would be great for that, as it would allow all Firefox OS users to have access to our app immediately, and it's something they could use daily!

1 comment:

  1. Why can't:

    var json = args.json;
    this.json = json;

    be just:

    this.json = args.json;

    ?

    Also, I couldn't read about "App Preloading" since would need to sign into an account (which I don't have).

    ReplyDelete