Tuesday 12 December 2017

18 months?!

Someone at work this week commented that my blog was not exactly up to date and they weren't wrong.

I have spent a lot of the last 18 months helping my wife with her business (http://www.leaveyouregosatthedoor.com/) albeit it in a IT capacity rather than anything else. As well as what seems like a multitude of websites some of this time has been spent building a mobile app for her.

I always tended to write things from scratch when coding on RISC OS but these days the wealth of freely available tools and libraries means there are no good reasons for doing this and nowadays I tend to look for shortcuts.

When I approached writing a mobile app I naturally gravitated towards Android as this is my mobile platform of choice. Big problem. My wife loves her iPhone. I really didn't have the time to natively code an Android and iOS app and these days I find my brain is getting a bit too full to be learning new technologies at the pace I used to be able to.

Hybrid development

I had previously encountered a cross platform mobile framework called Cordova created by Apache and a variant of it called PhoneGap packaged by Adobe. It was fairly obvious that if I want to write a highly performant app then this might not be the way to go, but I didn't need that so I thought I'd give it a go.

This framework allows you to code in HTML, CSS and JS (I prefer jQuery, but most modern web frameworks would have been fine). It also provides a way to access the native capabilities of the phone such as camera, location services and storage via a healthy range of plugins.

User interface

One thing I wanted that wasn't provided was an easy way to support the native look and feel of the target device. Sure I could build my own CSS to do this, but that would be tedious and time consuming. I settled upon the Onsen UI framework to take care of this for me. This will give a iOS or Android skin depending on the device on which it is running.

Storage

The app has some requirements to be able to store class and course information on the phone so they can be viewed when offline. When I started I used the local SQL capabilities of the phone and kept it up to date using remote web service calls when online.

This worked OK, but updating the schema of the database was tedious and error prone and keeping the data in sync was a little clunky.

Firebase

I was already using  Firebase to send push notifications to the phone and for crash reporting via some of the aforementioned Cordova plugins. I then investigated their Firestore offering.

This is pretty clever stuff. You register a listener against a database on the device with is automatically synced to the version in the cloud without you needing to do anything. Change something in the cloud and it syncs to the device, fires an event and you can refresh the page. No connection? No problem. It transparently handles the synchronisation when you next get one.

And it's fast. Make a change to the database in a web browser and almost instantaneously the update is pushed to the phone.

Only one problem. No Cordova plugin. Maybe it was time I did make the effort to learn a bit of new technology. Writing the Android version was OK - I code in Java at work and there were some good existing plugins to learn from.

iOS was less fun. I consider my C and C++ to be reasonable if maybe a little rusty. How difficult could Objective C be? Oh, and the lack of a Mac to run the XCode IDE on....

The Mac problem was resolved using VirtualBox surprisingly easily - and I have to say I am very impressed how well MacOS runs in a fairly small VM. Much more performant than Linux or Windows on the same spec.

Objective C? Well once you get used to it, it isn't that bad...

End result

So although it will continue to evolve, the app is live on Google Play and I hope at some point soon on the App Store.

The Cordova plugin is available on github and via  npm.

What seemed a relatively simple undertaking did end up causing me to learn a lot of new things but also enabled me to give back a little to open source community via the Cordova plugin.

I'm just glad I didn't decide to try and do it all myself!

The cover page
List of available classes
Class specific details
Guide to some poses

Saturday 4 June 2016

Nothing beats fixing a 12 year old bug!

Pretty much for as long as I can remember, Sourcery has exhibited a strange problem where it will just stop in the middle of compiling a project. I tried a number of times to find the problem but it was so intermittent that I kind of left it alone.

When I started Sourcery it was on a StrongArm RiscPC. I then migrated to VirtualRPC first on Windows XP and then on Ubuntu.

More recently I have been running RISC OS 5 on RPCEmu - the latest version of this is so good - as well and this is when the problem really started to show itself and I was finally able to track it down. Partly because I had to and partly because looking at the code again after a few years let me see it in a different way.

The problem? When firing off a task to do the compilation I was assuming that when the task handle that came back was 0 then I didn't have to do anything because it had failed. In fact, on newer hardware the compilation stage was just so fast that it was finishing immediately.

The previous intermittent failures were due to the very occasional  task finishing very quickly.

The lesson? Read the PRM more closely.

I wish when I had started coding on RISC OS the concept and support for TDD had been something I was aware of. Any Java coding I do now is always TDD. Both the safety net of coming back and making changes at a later time and knowing you haven't broken anything, and the way it makes you think when coding do lead to much better software.

That's not to say it's a silver bullet. You have to be disciplined enough to do it and to keep the code coverage high.

Thursday 19 May 2016

Welcome!

Welcome to my new blog. It's quite likely that this won't get updated that frequently, but any new updates to the site or releases will get mentioned.

With that in mind, welcome to the new look Really Small Software Company website. Updated with a fresh new look and with mobile access also in mind.

Sadly this does mean at the moment it may not render 100% in NetSurf. The undesirability of this situation is not lost on me, given that many people who visit this site will be RISC OS users.

However, many won't be and many who are will be well used to traversing the web with other browsers.