Programming

On Code Comments

Actual source code from Microsoft Word 1.0 for DOS

Actual source code from Microsoft Word 1.0 for DOS

This post is basically a bookmark for me to come back to and remind (berate?) myself regularly about my comments that I write in my code.

Not that I should do more. I actually put in a heck of a lot of comments in my code, because I know my memory is poor.  Especially so when I have done several late night programming sessions in a row.  I once even completely forgot that I had written an entire application after a month of sleep deprivation.

What prompted this post is the fact that I often find myself coming across lines or blocks of code that are commented out.  Without explanation.

Just today, I had to go back into some 2 year old code, because a client had reported a possible bug that wasn't bringing pricing across properly from their legacy system.

It took me a while to re-understand my code, and that was helped by the copious comments I had left, knowing my own mental fallibility.  However, when I finally got to the section of code that did the pricing import and looked at it, I immediately knew what I needed to do in order to effect a fix.  BUT then... I noticed that there was already two lines of code EXACTLY like the ones I was about to put in.  Only they had been commented out by me previously.

Why?? What made me comment out those two lines in the first place?  Did they introduce yet ANOTHER serious bug in the system?  There was no notation as to when the lines were commented out, nor any indication of WHY I had done so.

The 'when' is an easy fix.  I just need to go back through my version control system to work that out, but the 'why' is an altogether more puzzling conundrum.

I'll be sure to leave some comments in this section of code reiterating my journey to write, then comment out, then uncomment the alleged lines.  Perhaps in another year or so, I will come back to it and have to unravel this veritable Gordian knot of commentary.

App #3 - Spotto

Ok, just submitted app number three to the app stores yesterday.  This time, a gaming app called Spotto.  This app is basically a rehash of the old kids game we used to play when we spotted something that was pre-designated during an outing or a road trip, and the first person to call 'Spotto!' won a point.

Well, with this app, any player can create a game, which can be for spotting ANYTHING at all - whether it is a brand of car, colour of show, breed of cat, style of architecture - whatever.  Other players can join the game, and then post pictures of the said items.  All players in the team can approve or dispute entries, and points are awarded for approved entries.

The game is open ended, and self regulated.  It was an especially challenging one for me to write, as this was the first time I was using a NOSQL database (Firebase, from Google).  After years of SQL programming, getting my head around NOSQL structures and capabilities was a real challenge, but I think I got there in the end.

The other thing was that this app was designed to be fully real time - i.e. as soon as an entry was entered on one player's mobile device, the other devices all updated at the same time.  This was also quite challenging, however the Firebase API helped a lot with this.

In the same vein, I had to get my head around push notifications, and also use Facebook login authentication for the first time.  All fun, but it all came together fine in the end.

Spotto should be available in both stores by the end of the month.  In the meantime, feel free to visit the Spotto website for more information.

Keeping the momentum going!

Well... Last post I mentioned about the app that I wrote in under 2 weeks and submitted to the app store.  It turns out that once you get the ball rolling, it is mighty hard to stop.  Which basically means that in December 2014, I ended up writing not ONE, but TWO apps and submitted to the app stores.

After I had finished development on BlissBank, I was on a high.  Intellectually and energy wise, I felt like I was crackling and needed to keep those creative juices flowing.  So even as I finished hitting the submit buttons on the app store, I was starting to create the framework for another app - MusicKata.

MusicKata is closer to my own heart, as it combines my passion for music and programming.  I have always struggled with practicing the songs I want to learn on guitar, especially complex fingerstyle or classical pieces.  Once someone said to me - "Wow, you must have spent HOURS practising that piece!".  To tell the truth, I hadn't a clue how many hours I had spent on it.  I guessed maybe 20 or 30 hours, but I thought it would have been good to know an accurate figure.

That is why I wrote MusicKata.  'Kata' is the Japanese word for a form or a practice routine, and I thought it would be apt for this app which helps you to track your practice time over many pieces, as well as help you with that practice via providing a steady metronome for scale exercises etc.

The other thing that I thought I would like to know is an exact measure of how much I have improved over those practice sessions.  I thought that it would be nice if I could go back in time to hear just how bad I was at certain sections back in the early days - if only to reassure myself that I *was* getting ahead now.

So, MusicKata has the ability to record short snippets and store them against the piece, so that you can review them later.

Hopefully this app will be ready on the app stores in January 2015.  I feel elated to have accomplished so much, yet a little mentally fatigued after an intense month of programming.  I am not sure if there will be a third app issuing forth in the near future.

My 30 day app challenge...

About a year ago, my wife approached me with an idea.  It was the new year, 2014, and she was lamenting over the fact that she felt that we had not achieved the goals we had set out for ourselves back in 2013.  "Wouldn't it be nice" she said, "if there was an app that would let us set some goals, then allow us to track our progress towards those goals, and perhaps pop up a reminder from time to time to let us know we are on track...".

We searched around the app store, and while there were apps there that came close, none seemed to fit the bill.  "We should write that app!" she declared.  I nodded in agreement, but in the back of my mind, I know that my current 'real' work schedule didn't give me much spare time to even contemplate such a project.  We put together some vague specs for the app in a Google Doc, but it basically just sat there gathering dust.

Fast forward to the beginning of December, and I caught myself remembering that conversation from earlier in the year.  I realised that once again, we had fallen into the old habits of letting goals slip by in 2014.  After all, wasn't the idea to write a goal tracking app a goal in itself?

I had the usual end of year madness upon me, with clients wanting projects finished before the Christmas closure, but I looked at the vague specs my wife and I drew up earlier, and decided "Right!".  

I was going to do this.

Not only was I going to do this, but I was going to do it before the end of the year, so that the app would be ready to go out to the masses for the New Year 2015.  That gave me 30 days.  Factoring in the 2 week average approval period for the Apple App Store, it meant I would have to submit the final product for approval by mid December.  Time to get to work.

My first question was "Which platform?".  Both my wife and I are iPhone users, but my son has an Android phone and I wanted to cover both bases.  We decided iOS and Android would be the main platforms.  Windows, Blackberry etc. may have to come later.

Second question was "Which technology stack?".  I already had some familiarity with jQuery Mobile and PhoneGap etc., but I wanted a little more.  Then, I came upon a framework called Ionic, which is a mobile development framework based upon AngularJS.  When I first saw the demos for AngularJS, I went "Whoa!" in an excited way as I saw two way data binding etc. in action.  Then I delved deeper and looked at the code behind the scenes and went "Whoa!' in a kind of horrified, opening Pandora's box kind of way.

It certainly wasn't going to be an easy framework to get to grips with.  New methodologies and protocols such as Directives, Services, Factories, Promises etc. would be a completely new way of thinking about app development than what I was used to.

Nevertheless, I rolled my sleeves up and dived in head first.  Being a relatively new framework, Ionic questions and tips were hard to find on Google or StackOverflow.  Lots of things were trial and error.  Also, being on the 'bleeding edge' of current app development tools, there were a lot of incomplete things or things that would change literally overnight.  I would be in the middle of a late night coding session and would get a message saying that a new release was available.  Sometimes twice in the same evening!

One of the saving factors was the excellent community around Ionic, AngularJS and Cordova.  Plenty of REALLY smart people who are also generous with their time and knowledge.  I found some great blog posts which covered the areas I got stuck in, such as using SQLite databases on a mobile device via Cordova and Ionic.

Well, not 9 days later, we had an app ready to submit to the two app stores.  Not even I could believe it.  In reality, I had finished the first 1.0 version in about 6 days, but then when my wife and I tested the early version, we realised we wanted a few more things in there, so I went back to work to add more features.

Some 'simple' sounding features, like local notifications, proved to be a lot trickier than I imagined.  But once again, the Ionic forums came to the party and I found the answers there.  I even managed to improve on one of the answers a bit myself, and contributed back on the forums, so hopefully someone else in the same boat can get through the issue quickly.

Finally, on the evening of the 13th December, we submitted the app to both stores.  It is called BlissBank (which is the name my wife came up with) and hopefully will be approved by Apple by the 31st December.  There are still lots of things that I wanted to add to the app, and to clean up within it, but for now it appears to be stable, and will at least give us the chance to get a small user base together and get some feedback before we develop the next version.

It's been a long time since I went 'heads down' with such intensity on a project.  But being a personal project, and the brainchild of my own wife made it special and added a lot of incentive.  Kudos to my wife for giving me total support and allowing me as much time as I needed to go hard at this project too.  She took care of the other normal distractions around the house, like taking the kids out for long outings etc. to give me space and quiet.  Especially seeing as she was in the middle of launching her first art exhibition.

Now, I just have this one other idea for an app that would be useful for the New Year... Hmm... wonder if I can squeeze that in...