RUVacant – Downloading Rutgers Data – Devlog 2

Wow. It has been A WHILE since I last posted. Mostly because I’ve been dedicating little time per day to work on this project, but this week I’ve made sure to put as much time as I can. I really want to make a lot more progress!

Anyway, I’ve gotten one of the main features of the app implemented, which is the downloading of Rutgers data!

Technologies I used

Something else I also experimented with was JUnit. I wish I started using it a long time ago. It was so convenient to be able to just run one method of code, rather than having to run the whole app just to see if my code is working. In the past, what I did was I ran the whole app and either used logs or TextViews to see what data is showing up, or whether what I wrote was working correctly. Terrible I know!

Though one thing I’m unsure with JUnit is testing asynchronous code. I know I can use TestObserver and its await() function to wait until the observable calls complete. Though, there where times where I did not have direct access to the observables, so instead, I used Thread.sleep() and hoped it finished so I can look at the data that was returned from the component containing the observable. It worked most of the time, but I feel like it might’ve been a terrible solution? Not sure yet, but I’ll definitely look that up later.

I’m really glad I decided to scrap my old code and start over with this project. I was being lazy with the old code, and didn’t really truly read the documentations for both Room and RxJava. When I used these technologies with the old code, I was having a lot of issues since I didn’t really understand them very much. For example, I was having a lot of SQL constraint issues when using Room. Part of the reason for that is I did not spend enough time looking at the Rutgers data as well, so sometimes I thought some fields were always unique and made them primary keys, when they were actually not always unique! Also, I was using RxJava because I saw some solutions on StackOverflow, and used them but didn’t truly understand them. I truly made some poor decisions with the old code, and now I made sure to really learn these technologies this time!

Working with heavily nested JSONs

Is there a better way to work with nested JSONs?

I cringe at the amount of nested blocks there are. Instead, I organized this to smaller, many separate functions. You can still see some nesting, though not as much at least.

More questions I have, more things to learn

While I was going through this part of the project, there were aspects that I didn’t fully understand. Like the HTTP clients. I’m not too experienced with networking, so this is definitely something I need to learn someday! For example, I wasn’t too sure how long connection timeouts should generally be. Is there a best practice as to how long they should be? Should I be setting timeouts to reads and writes as well? These are definitely more things I should learn!

Another thing I really questioned is how the Rutgers API saves time information. The Rutgers API provides information for each class meeting, including what building and room it takes place in, what course it is, and the start and end times. The one thing I really don’t understand is why they save the start and end time as a string, like “HHMM” with a boolean representing whether it takes place AM or PM. What is the advantage of saving time as a string? Is it more advantageous to a number, like an integer, stored as the minute or second of day, which is what I did for my application? I felt it would be easier to use basic math to convert it into its respective hours and minutes, rather than having to first parse from a string to a number format. Are there advantages I’m not thinking of? Thinking deep within computer architecture, like assembly, is parsing a string faster than mathematical computations? Maybe that was done because it was easier to read? Maybe I’m thinking too much about it, though I am definitely just curious to know the reasoning behind it.

Godsends

There are some technologies that once I use it, I can never go back to not having it. A general example would be Vim (or Vim-like features). I can never go back to coding using the mouse or the arrow keys. Vim is a Godsend. Period. Not using it makes me feel sluggish.

And then there are the technologies I use as a part of implementing RUVacant. For example, Android Studio’s automatic code generation features are also Godsend. I don’t want to spend my time writing individual getters and setters for every single field in a class. Need a default toString() method? Just automatically generate it. Need a default constructor? Just automatically generate it. Know what I mean?

Another one I also love so much is the Android Database Debugger library for Room (https://github.com/amitshekhariitbhu/Android-Debug-Database). With this, I can inspect the database on a nice and clean user interface on the browser. I can inspect each table for correctness, edit the data, delete the data; its another Godsend.

Reflecting progress on the UI

And finally, upon successfully implementing the data retrieval and saving features, I was finally able to have the UI reflect the application’s progress. In the gallery below, you can see the different images which reflect what state the application is in, as well as a progress bar.

Next steps

I can finally start working on listing all this data on the next activity! I haven’t designed the architecture and components of that part of the application yet, but that will be what I’ll be getting on to! Likely, I won’t be working on it next week, as I’ll be learning MERN for a hackathon project. But I’ll try to get on it as soon as I can!

As always, thanks for reading my post!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: