Monday, October 5

Pencil and Paper Battleships

School holidays and I wanted to spend time with my daughters. I remember how I used to play Pencil and Paper Battleships with my brothers. I do a search and none of what I find is anything like what I used to play with my brothers. So I made up some sheets from memory and they were a big hit with my daughters.

Maybe a kind reader could tell me where we got these rules from. I am not sure weather we made them up or got them from somewhere else.

Burns Family Rules for Battleship

Place the following battle units on the “Your Ships” grid. The units can be rotated or flipped to face any direction. However they cannot be placed running in a diagonal direction. Units cannot be placed next to each other. There must be at least a one square gap orthogonally and diagonally between each unit.

The following ships must be placed in ocean squares on the grid.

The following air units must be placed on any squares on the grid.
The following ground units must be placed on land squares on the grid.

Now that all units have been placed on the grid. Each player takes turns guessing the location of their opponents “Ships”. They fire off a “shot” by calling out the ‘Letter’ and ‘Number’ of a location on the grid. Their opponent calls out ‘Miss’ if they have nothing at that location and ‘Hit’ if they do have something there. If all squares of a ‘Ship’ have been hit then the opponent announces the type of “Ship” sunk and the fact that it has been destroyed. The tally box of the ‘Ship’ (to the right of the grid) should be crossed out when a “Ship” is destroyed. The first player to destroy all their opponents ‘Ships’ wins.
Three times in a game a player can use a mega-bomb. Mega-bombs hit everything at the called location and all 8 adjacent squares. The opponent calls out any hits from the bomb and their location plus the names of any ‘Ships’ destroyed. Cross out an ‘M’ tally box each time you use a bomb.

Game Sheets 

Thursday, October 1

Source Code on Github for Simple Card Game written in Swift

I knocked up a simple game in swift using SpriteKit as part of a job interview. Its based on a game my family plays all the time using real physical cards. I put it in the app store under the name Rickety Kate and uploaded the source to Github. You might find it takes 8 to 16 days for the code in the repository to find its way to the app in the App Store, one and half review cycles on average.

I probably over engineered this one. You can build your own deck of cards, anything from a 40 card deck with 4 suites to a 140 card deck with 9 suites. I knocked up some very simple input controls to control the options.

Putting 1x and 2x images  in texture atlases was a little finicky. I did a little experimentation and the 2 versions of the images seem to need to be in the same atlas for the 2x images to be automatically used in a retina device. Also here were problems unless all images in a atlas had the same number of versions e.g. they all needed to have 2x versions or none should have them. I have not tried using 3x images yet.

I am going put out a series of very simple games and apps. One per week for a year. Next one is going to be a tilt game with retro neon line graphics. Set in the wreckage of a large city post alien invasion, you pilot spacecraft picking up refugees, and ferrying soldiers, diplomats, wounded, equipment and supplies while avoiding Lurkers, Tripods and Space Jellyfish.

This is going need focus and prioritisation. No more going off and creating 143 images for playing cards even if I leveraged pre-existing art rather than start from scratch.

Update: Rickety Kate 1.0.1 Just passed review. Its still a week behind what is in Github though.

Wednesday, September 30

Is it worth while transitioning from Objective C to Swift?

I 'm late to this bandwagon. However I had a heavy investment in an Objective C code base and a lot of distractions. Enough with the excuses, better late than never.

I know others have held off for many of the same reasons I did. So the question is useful. Was transitioning to swift worth it? The answer is a definite yes.

The Pros

No pointers and no nil-able values or objects unless they are wrapped in an option. This cuts down on a large class of errors.

Named parameters. This language is targeted for Objective C programmers so of course it has name parameters, however I still count it as a plus because named parameters increase readability and are a good idea, even C# has named parameters theses days.

No lisp-like nested square brackets everywhere (yes I know lisp uses round brackets, however I am talking about the nesting behaviour)

Immutable values using the let keyword. This reminds me of Scala's val and var keywords and of F#'s let keyword, although F# makes it harder to make values and objects mutable. Immutable values can make an application easier to reason about and make it easier to do concurrent programming (less need for locking)

No more header files.

Memory management that doesn't feel like a tacked on after thought .

Only one form of closure instead of the two different flavours in Objective C (selectors and blocks)

The 'if let' statements ability to chain together multiple let statements capped with a where cause reduces nesting and as nesting plays havoc with readability this is all to the good. There is a 'if var' version but I never see it used.

Swift has its own REPL which in Swift's case is called a playground. REPLs are common in many interpreted languages, they are ideal for learning and experimentation. REPL is pronounced 'reppel' and stands for Read Evaluate Print Loop and at its heart in a very simple, effective and old piece of technology.

No more need to box and unbox value types just to use collections. I remember when C# had this problem (versions 1.0 and 1.1 fixed in 2.0), but at least C# 1.1 had the __box and __unbox keywords,  in Objective-C you have to wrap and unwrap value types by hand.

Swift has generics, type safety and even type inference. Plugging that hole (lack of generics) in the type system pays off massive benefits in reduction of errors and increased ease of use. There is no way to have general purposes containers like lists and dictionaries without either having a generic type system, using dynamic types or breaking the type system by casting away type.

Less use of special characters in syntax, no more semi-colons at the end of your lines and a more modern cleaner looking syntax.

Initial Annoyances / Gotchas

You will need to lose the habit of surrounding if conditions with brackets as this can break things. This is initially is frustrating, but when you get used to it, it actually looks cleaner.

Significant white space between operators and operands or lack there of will turn binary operators into prefix unary operators.

Xcode habit of warning you that you have not used a declared variable or constant straight after you have declared it and before you have had the chance to type the line that will use it, can initially be distracting.

The Cons

I am used to uninformative and obscure error messages, but Xcode has reached a new low in this lost art of sowing confusion. After a while you get an idea about what it could be complaining about, but even when you know what is causing the problem, drawing a meaningful relationship between the error message and the cause of the problem can be bewildering.

The navigation and intellisense  tends to break when you need them most.

No refactoring support for swift yet compared to Xcode refactoring support for its other supported languages, not that Xcode Objective-C refactoring support is terribly good, but at least its there.

Lost Opportunities

There is a lot I could say about this, but Objective-C does worse in features I want to complain about so I will just point you to a post that Rob Napier wrote about how swift is not functional and save the rant I was going to write here for another blog post.

The Experience

The first one or two weeks was frustrating. Most of the frustration was centred around the compiler. However the learning curve was surprisingly easy. After two weeks I felt more comfortable with Swift than Objective-C even though I have been using Objective-C for years. Their is very little in Swift that isn't a standard expected feature in a modern programming language. Even the syntax and the keywords are pretty stock standard. Given the blandness of Swift the main reason for its existence is obviously to have built-in compatibility with the existing libraries and APIs and to make migration from Objective-C and interoperability with Objective-C easy. In achieving these goals Swift is successful.


I am not going to rewrite all my Objective-C code base in Swift. However all new work is going to be in Swift and even major modifications to old projects will probably be in Swift as you can mix the two languages in the same project.

Tuesday, September 29

The Secret to Managing Images, Sounds and other Resources for Mobile Apps

Four simple rules
  1. Automate, Automate, Automate
  2. Keep all the source artefacts and scripts needed to produce the final resources under source control e.g git or mercurial (don't bother with the derived images)
  3. Give everything long descriptive names and a systematic logical folder hierarchy.
  4. Use texture atlases rather than individual images ( originally I used Zwoptex to generate texture atlases for me, but now days Xcode does it automatically for me ).

When you first start adding images and sounds to your app it doesn't seem like a big deal to do things manually. Any half baked semi-functional  process or algorithm works as long as 'n' is small. But as the number of images and sound clips grow you will pay a higher and higher price for poor decisions you made at the start. It does not take long before you have hundreds of images and sounds. Any technique that allows you to cut down the number of images is a technique you should use. A favourite trick of of mine is to split an image into several layers and to tint one or more layers programatically to get several different colour themed images.

One of the reasons images breed like rabbits is the different resolutions and aspect ratios of different devices. Making different images for each device manually is the road to insanity. There are two different approaches to get around this problem and I use them both.

Solution 1

Make your images at the highest resolution and then down sample to get your lower resolution. One of my favourite tools to do this is ImageMagick as it has a command line interface and therefore can be called from a script. You can use it to resize, crop and rotate images plus much, much more. If I am using a Mac prefer to use the MacPorts package manager to install apps like this, if I am using Windows I use the Chocolatey package manager.

Once you have a package manager  you type in the following into the terminal for the mac
sudo port install ImageMagick
or the following into the command window for Windows
choco install
Nicholas Waynik has a tutorial on how to use the resulting images on the iPhone and iPad.

Solution 2

Use a vector format like SVG and then you can rasterise it to any resolution you want. I tend to use this solution as I have the habit of going back and spitting my old images into parts in order to animate or reuse the image in someway. It is easier to modify a vector image later if you have to. Inkscape is a good drawing app to use for creating the images.

It does have a command line interface but you have make it jumps though hoops if you want to make it rasterize an entire folder of vector images. Which is exactly what I am always going to ask it to do. You do not want to create the final rasterized (e.g. *.png) images this manually though the GUI. Remember rule number 1. I use the following snippet in the bash scripts I use to generate the final images.

for i in /full-directory-path/*.svg; do /Applications/ $i -w 100 -h  200 --export-png=`echo $i | sed -e 's/svg$/png/'`; done

and for the 2x images

for i in /full-directory-path/*.svg; do /Applications/ $i -w 200 -h  400 --export-png=`echo $i | sed -e 's/.svg$/@2x.png/'`; done

You can either copy and paste these command into a mac terminal window or place them in a text file with a *.command extension to create a clickable command.

I modified the this script based on a piece of bash script voodoo I got from gastarbeiten who in turn got it from someone called forger. The original script no longer works because the upgrade to inkscape 0.91 broke it, thankfully it only took a minor tweak to get it working again. Fair warning these scripts sometimes need little care and feeding every now and again. I seem to need to fix them about once every 6 months. Despite the very occasional annoyance these scripts are a life saver.

Originally I used batik to do the rasterization as it supports processing multiple file out of the box without any fancy script voodoo. However a Java update broke the software and there was much pointing of fingers and little solving the problem. They have probably fixed the problem by now but I have moved on.

Wednesday, May 14

HIring Staff

This is a skill that most people believe they can do without training and yet most hiring managers do not get the results they desire.

There are studies that show that unstructured interviews do worse than chance ( most interviewers would be better off tossing a coin). The authors of these studies generally then go on to recommend some form of structured interviewing technique.

The main advice I would add would be to keep metrics on the success of your hiring process, continually refine the process based on those metrics and understand the needs of the role you are hiring for.

I have been collecting metrics and statistics on not only my hiring decisions but my co-workers hiring decisions for 14 years and my personal experience is in total agreement with the scientific literature. Hiring is easy to get wrong and it is rare that hiring managers get any training.

The biggest mistakes I see are :-

Mistake 1: Trying to hire someone who would be good for any role - you need to start from a good understanding of the day to day needs of the role you are hiring for. Concentrating on the most common and most important and most error prone tasks.

Mistake 2: Choosing between soft and hard skills - The employee needs to both be able to do the job AND to work with others. Deciding based on one half of the equation and thinking you will train them up on the other is the road to heartbreak.

Mistake 3: Talking and not listening. If there is information they must know encourage them to ask questions. Their questions will tell you something. You talking will not.

Mistake 4: Assessing based on the type of questions you were assessed on at school. You are not interviewing them for the position of university student. The assessment needs to be as close to the real life tasks and behaviours the role requires as possible. 

Mistake 5: Assessing on too many criteria - The passing grade for each criteria will be lowered and the time assessing fit for each criteria will be shortened if you try to fit to many in. Prioritise, Prioritise, Prioritise.

I usually go for a technical test that is realistic and as practical as possible for the hard skill component. In theory their is no difference between practise but in practise there is. 

Plus Behavioural Interviewing questions for the soft skills.

Failing on either the hard skills or soft skills is a fail.

I prefer depth to breadth. Hauling them over the coals on a few questions rather than let them bluff their way through a dozen. Remember in school how easy it was to bluff your teacher? Alternatively do you help your children with their homework and watch them bluff their way through? Be tough and drill down into the details.

Common mistakes when capturing the needs of the role :-
  • Recency Bias. People overestimate the frequency of events that are recent.
  • Capturing everything. Some activities are more important than others. Some are easier to learn. Some are more frequent than others. Prioritise.
  • Should do vs actually do. People will report that they are behaving the way they think they should behave rather than what they are actually doing. Sometimes their actual behaviour is more practical and productive than the rule they think they should be following. Either way encourage people to reflect on their experiences.
The biggest mistake of all - Thinking that you can not do better.

Sunday, March 18

Created an interactive book for new readers on the iPhone / iPad

I have released my first iOS App A is for Ant

Designing and implementing this App has  been a fun exercise that has allowed me to get up to speed on Objective C and to explore a few ideas I have had about educational software.

For $0.99 you get:

A beginner reader story book (with easy, medium, and  hard versions) plus 13 games.
Easy version of the Story
Screen shots is from version 1.6.4 and the video is from version 1.4.5

Medium version of the Story
Hard version of the Story

Colour in Drawing

Solve jigsaws 
based on each page of the story
Matching game stimulates memory
 and letter recognition
Sound matching game promotes listening skills 
and phonemic awareness
Tracing game 
to help practice writing letters

Picture and Sound Game promotes listening
 and letter recognition. 

Word finding game promotes spelling
 and word recognition

Picture game that promotes creativity
Word Matching Game 

Match words with sounds

Match words with pictures
Sliding Puzzle
Flash Cards

What it looks like on an iPhone (YouTube Video)

What it looks like on an iPad (YouTube Video)

Apple taking a while to review the app this time.

Tuesday, October 4

Smoothing the rough edges from life

f you are like me, if you are like most people; you are plagued by a slew of irritations, annoyances and frustrations throughout your day.

You ignore the frustration as you find workarounds and coping mechanism to overcome the road blocks placed in your way, in order to achieve your immediate goals.

Instead of ignoring these irritations I urge you to treat them as important signals that show where you can improve your life: that you isolate each of these annoyances and, remove them permanently from your life by applying a complete solution to the root cause of the problem, instead of engineering temporary workarounds to alleviate the symptoms. In this way your life is gradually improving as some of those repetitive issues stop reoccurring.

One technique that I have found personally useful is asking why five times. It has been made famous by Toyota which introduced it in the 1970's. Toyota credits the 5 why's technique with accelerating their process improvements.

As an example of how this can be used, many years ago I found that I was constantly tired, pushed to the point of exhaustion. I asked myself,
  • 1st Why "Why was I tired?" 
    • 1st answer "I was stressed"
  • 2nd Why "Why was I stressed?" 
    • 2nd answer "I was not sleeping well"
  • 3rd Why "Why was I not sleeping well?" 
    • 3rd answer "I was stressed, also I was exercising less than I used to"
  • 4th Why "Why was I was exercising less than I used to?" 
    • 4th answer "I had fallen out of the habit"
  • 5th Why "Why had I fallen out of the habit of exercising" 
    • 5th answer "I did not have I regular time scheduled time for exercise"
If you ask the 5 whys at a different time you often come up with different answers. Some people think this is a weakness, personally I think it is a strength.
Let's ask the 5 whys a couple more times.
  • 1st Why "Why was I tired?" 
    • 1st answer "I was stressed"
  • 2nd Why "Why was I stressed?" 
    • 2nd answer ""I had too much to do"
  • 3rd Why "Why did I have too much to do?" 
    • 3rd answer "I was not prioritizing my task enough"
  • 4th Why "Why was I not prioritizing my task enough?"
    • 4th answer "Too many the tasks were rated as important"
  • 5th Why "Why were too many the tasks were rated as important "
    • 5th answer ""I had trouble letting go and accepting that some tasks would have to be done latter"
And again.
  • 1st Why "Why was I tired?" 
    • 1st answer "I was stressed"
  • 2nd Why "Why was I stressed?" 
    • 2nd answer ""I had too much to do"
  • 3rd Why "Why did I have too much to do?" 
    • 3rd answer "I said yes too often when I should have said no"
  • 4th Why "Why was I not saying no?
    • 4th answer "I did not want to disappoint people"
  • 5th Why "Why did I not want to disappoint other people"
    • 5th answer "I needed to tell myself that it was better to disappoint them now rather that rise their expectations then disappoint them latter.
I turned these why's into solutions. I started seeing improvement after I
  • started exercising at the same time every morning
  • made sure that only limited number of tasks were highest priority and
  • I only accept new tasks when I had either completed old tasks or downgraded old tasks in priority.

You do not have to be Toyota to benefit from root cause analysis. Anyone can do it. When faced with a repeated annoyance, just ask why five times.

Thursday, August 11

Online Resources for Software Developers

I facilitated a brown bag lunch for the company's developers today. The topic for the brown bag was online resources that are useful for software developer in their work. We came up with a list of which I have recorded in the following section. It is far from a comprehensive list, however it contains some interesting and useful resources.

Code Katas and Koan

These are exercises to help you to learn elements and features of programming languages.
Examples as follows


These are Internet radio shows often in either a interview style or a panel discussion style
Examples as follows>


These are screen capture videos of people demonstrating technology.
Examples as follows


These are Internet TV shows often in a interview style.
Examples as follows
  • FLOSS Weekly about open source software
  • InfoQ Tracking change and innovation in the enterprise software development community


MOOC stands for a Massive Open Online Course.
Examples as follows.


These are thread based discussion groups often centred around a particular technology
Often better for answering questions if the technology is niche.
Examples as follows

Question and Answer Sites

The members of these sites help each other by asking and answering questions
Often better for answering questions if the technology is common.
Examples as follows
  • StackOverflowis a programming Q&A site that’s free. 
  • Anyone can ask, answer, or edit questions on  Quora
  • ServerFault is a Q&A site for system administrators and desktop support professionals that’s free.


Rants, tips and tricks from those in the know.
Examples as follows

Events and Meetups

These sites help you find out what is happening in Melbourne

Sample Code and Code Projects

These sites give a more in depth treatment of problems
Examples as follows


  • The Wayback Machine. Have a broken link? An important resource that has disappeared? Go back in time and find it. 
Does anyone have some useful online resource that they would like to through into the mix?