Category Archives: Technology

How to test services that make async network calls in Swift and return an Optional

One of the things that threw me the first time I did iOS development was the fact network calls were done asynchronously by default. From an implementation side this was nice, I didn’t have to worry about blocking my main thread. But from a testing side… well that was something new.

Since then Apple’s come out with Swift. And with Swift comes the need to learn new ways to do things.  A couple of things I wanted to work out how to do nicely was:  how can I stub out my network layer as I don’t want my test to have to run against a dummy backend, and secondly how can I assert the Optional value I get back is set.

Turns out it wasn’t too tricky. The optional var was set as a result of an async call, so the easiest way to check the value is to first wait till the var has a non nil value.

And stubbing out the network layer was easily achieved by using OHHTTPStubs.

My final test ended up looking like:


YOW! Connected 2015: Bridging the Designer – Developer Divide by Chris van Raay

I had the opportunity to go down to Melbourne for the YOW! Connected 2015 conference. It’s the second YOW! Connected to be held and even though it was at a smaller venue this year I enjoyed it just as much as last year.

What I enjoy about conferences is it’s a chance to hear how other people are doing things, get interesting insights and things to look into. And lastly to somewhat reassure you that as a developer (and organisation) the decisions you’ve made so far have actually been sensible choices. When you’re sitting in an audience and multiple speakers are mentioning things along the same lines there definitely is a sense of relief in a way.

But back to the conference. Whilst the conference covered both mobile development and the IoT, I mainly attended talks leaning on the mobile development side. For me there were two running themes in this space:

  • Designers and developers working together
  • The use of reactive programming in mobile development

There were also a few talks on mobile app testing, CI and CD that reaffirmed for me the state of testing for mobile, the decision we’ve made so far and where we can go next.

I’ll focus on trying to get up my notes on the designer and developer talks first as there were 3-4 talks on this topic. Whilst every talk had differing ideas on how designers and developers could work better together the crux of it all was communication and having a shared understanding.

Bridging the Designer – Developer Divide – @chrisvanraay

Common issues in the divide

Chris opened by discussing a number of issues in the designer – developer divide and how they may be overcome:

Us and them mentality
Developers thinking ‘designers don’t know anything’ and designers thinking ‘developers are lazy. To help overcome this:

  • Designers should be experts in the platform they are designing for
  • Developers need to be honest. Nothing is impossible, just harder/hard to do.
  • Break down the walls and have respect for each other. Working in a cross functional team helps with this

Implications of design decisions
It’s not easy for designers to know what is easy/hard. You get get through this by simply talking and working through it together.

Point 1 in ‘Us and them mentality’ about being an expert will help in understanding the implications.

Speaking different languages
Designers and developers often speak in different terminology. Use a shared language. E.g. things you can standardise:

  • Are you talking pixels or points
  • Is it a screen or a view controller

Design isn’t always measurable
Developers need to understand design isn’t scientific and will have to be more patient.

Geographical separation
Easily overcome by co-locating/sit together. Also better handover docs (this is more relevant if you’re geographically separated).

PSDs are terrible docs for developers to use
These are often provided as the output of design for developers to use. They’re not ideal though as developers often don’t have Photoshop nor the skills to use it well. Designers could help developers learn enough Photoshop but PSD files aren’t valuable enough in itself.

Conflict isn’t a bad thing
It gives you a different view on things. But you both need to be able to compromise on things.

But at the end of the day designers and developers aren’t really that different. Your goals are really the same thing, just in a different language.

How/what can designers developers do to help bridge the divide?

How does a team overcome the issues identified above? There are a number of things that a team can do:

Have a consistent design
This means you have less things to build, as a common understand is shared between both parties. To achieve this there are obviously some changes/improvements that need to be made:

Designers can structure their work to make the transition as painless as possible

  • Communicate the design rationale
  • Documentation of the stuff you will look at every day. Things like font, spacing, colour palette
  • Use smarter prototyping tools
  • Handover a spec – if you’ve documented the common things, you can get down to just handing over a wireframe with the styles listed next to boxes.

Developers can do the following things better

  1. Code for consistency
  2. Code for change – Change is inevitable. Branding can change, apps get sold. Really this is the same as principle 1.

But how can we do all this?
A number of approaches we’re given on how designers and developers could help achieve the above:

  • Name your colours something easily understood. E.g. instead of saying ‘colour #8cd8fd’, maybe your team will call that colour SkyBlue.
  • Centralise colours – e.g. use a category to add your defined colours to UIColor.
  • Name your different font variations. E.g. H1 could be 17 point System Font.
  • Give names to combinations of fonts and styles so they can be references in wireframes. E.g. H1SkyBlue would mean the font is 17 point System Font in SkyBlue.
  • Document reusable views somewhere. This makes it easier for developers and designers to know what something looks like and refer to where it is already being used.
Why should we care about this all?

Everyone wants and loves working in a high functioning team. Happy designers + happy developers = a better functioning team. You’ll have increased flexibility and productivity and a general better working environment.

It was interesting listening to this talk as we’ve started doing some of the things mentioned above at work and the designers and developers already agree it is a better experience for both parties.

Is bridging the divide an easy thing to do?

Yes and no. You’ll need discipline and ensure designers and developers have both bought into the process. Things can get into the way like really strict rules on checking in code. All of these can be overcome if the team is willing to be flexible and do a bit of forward planning and creative allocation of work. E.g. if you’ve got a hefty design piece, split it down and sequence the stories in a ordered known way that makes sense. We’ve actually already started doing this at work and it’s been a much more pleasant process in getting design improvements delivered.



Creating an OS X VMware image using Packer

The time has come to look at OS X VMs. I’d put this off for a while as the amount of development I’d have to do on OS X didn’t warrant the effort. But curiosity, easier management of upgrades and the need to learn new things has spurred me on this path of learning.

So without attempting to chew too much in one go my first attempt is to create a VM image using Packer.

Why Packer? From one config you can create images for different platforms – like VMware, VirtualBox, AWS etc.

For my own learnings I was creating images for VMware.


  1. Have packer installed. If using homebrew simply run
  2. Have VMware Fusion or Fusion Pro installed
  3. Clone the os-x-vm-template project
  4. Have the installation file of OS X available. If you don’t you can download it as follows:
    • Open App Store
    • Search for the OS – in my case I looked for ‘os x yosemite’
    • Click download. It’ll download to /Applications

Creating the image

  1. Go to wherever you cloned the os-x-vm-template project.
  2. Run the script

    This will finish and chuck out some output similar to:
  3. Copy the template.json file in the packer directory
  4. Open the osx-template-vm-ware-iso.json file and:
    • Remove the builder entries for parallels-iso and virtualbox-iso.
    • Modify the iso_checksum and iso_url variable values to match the ones spat out in Step 2. E.g.:
  5. Validate that your config file looks okay:
  6. If your template is all good the next step is to create the image

    This step will take a while as it’ll create a new VM, install and configure OS X then export it as a new vm. The output will be created in a folder of the same name prefixed with output – e.g. output-vmware-iso.

Next up I’ll look at using this image as the image as the base source image to create other more specific images. Why do I want to do this? I want the ability to easy trash and recreate OS X environments but I want this to occur fairly quickly. By keeping a base source image I won’t need to sit through the OS X installation each time I need to start with a ‘fresh’ VM.

When social media works

Kudos to the @Optus social media team for utilising social media channels effectively to help their customers. I’ve had this ongoing saga for a few years where my internet drops out when the weather is extremely hot (around 35+ degrees Celsius). And with this many horrible experiences of Optus customer support – being on hold for 1+ hour then dropped out of the phone queue, passed between many departments, technicians not turning up because tech support decided there wasn’t an issue and cancelling the booking yet the next support person could clearly see the issue was still there based on the modem logs. After 3 or so call outs a new modem was provided about a year ago but since then there hasn’t really been a bunch of extremely hot days in a row.

Until yesterday… and woah behold when I came home in the evening no internet. Just the same flashing light sequence I’m more than familiar with. Usual tricks didn’t work and I was dreading having to call Optus tech support… Have you even been asked if you’ve power cycled you’re modem 3 times after you’ve already said yes twice? Not to mention the stuff arounds last time as mentioned above. So when it still didn’t work this morning, it was time to take to Twitter as I knew Optus have an account they they respond to.

Posted on the way to work, and got a reply within a few hours, and after providing a bit more info a guy from the social media team rang me – yes a real person! Turns out there were some issues which they knew about but with no ETA (odd that there network status page didn’t say anything). Anyways he said he’d try to keep my in the loop either via Twitter or ring me, and I got a phone call with an update in the afternoon that the issue had been fixed but there was someone else on my street experiencing the same issue so if it wasn’t fixed when I got home to get in touch. As I don’t get home till after the social media team finish for the day the guy updated the account notes with details in case I had to ring tech support for further help (tech support is offshore). Got home and lucky for me the internet was working again. Was it heat related? Don’t know the real answer but I wouldn’t be surprised if it was. The cables running from the house have to tap to the main line, so extreme heat could cause connector issues with expansion and all of joins.

That all aside, I was very happy with the customer service and give a +1 to Optus for embracing social media. The internet has reinvented the way people work, communicate and share. Businesses need to recognise and embrace these changes/technologies as they’re not going to go away. Operating models change over time and Optus is proving that they can address customer service in ways different from traditional means. Will customer service/support by social media become mainstream? Probably not, but it’s a market they have to catch as increasingly more people turn to the web for their needs (e.g. the whole online shopping debacle).

Back to WordPress

So after a bit of procrastination I finally bit the bullet and attempted the migration of my website back to using WordPress as the CMS. For those tech dudes out there, or those who follow my happenings, you might remember I started out on Blogger, migrated to WordPress than on to Drupal. My main reason for moving back to WordPress is that whilst Drupal was awesome as a CMS I predominantly use my website to blog, and for that WordPress  excels. If I had to run a fully fledged website, I’d definitely fall back to Drupal though as there are things that it excels at there.

I’d put off the migration for ages as there is no quick and easy way to migrate from Drupal to WordPress. You have no choice but to run SQL commands. On top of that I still had my original WordPress blog that I wanted to ‘keep’. I’d never bothered to migrate these into my Drupal site, but now I was going back to WordPress I wanted them all in the same site.

So for anyone on the web thinking of making the move back (or to)… here are the steps that I followed… Do make sure you take a backup of your database before hand though, as whilst these steps seemed to work successfully for me, they may not necessarily work for everyone. Hence take these steps as a guide only…

  1. Take a look at Convert – Import A Drupal 6 Based Website To WordPress v2.7 and follow the instructions there. Some differences for my setup is that I installed WordPress (Version 3.0.3) instead and didn’t bother to delete the Drupal tables as I was going to get my data back into Prod a different way.
  2. Check your development WordPress install and ensure it looks right
  3. OPTIONAL STEP: If you have a previous WordPress site that you want to keep content from as well, use the Export function in the previous install to download a WordPress export file. Import this into your new WordPress site using the Import function.
  4. On your development WordPress use the Export function to download a WordPress export file. This export files will contain all the data you want to use in your new site. E.g. in my case this was all my Drupal content plus the content from my original WordPress site.
  5. Install WordPress to your Production server
  6. Use the Import functionality to import the export file you downloaded in Step 4.
  7. Check that your Production WordPress looks correct.

Tech gadgets for the flashpacker

For want of a better word, I guess I could be termed a flashpacker. Cutting costs here and there is awesome, but a few nice things along the way be it a more comfy bed or hot water is always nice. That and the fact I seem to always cart off with me what seems an enormous amount of cables and gadgets.

This trip happening in a week and a bit isn’t that much different to the last few in terms of gadgets I’m taking, but I am throwing a few more into the mix. The Eee PC and Skype has saved me in the past and this time round I’ll be relying on it plus a bunch of other gadgets to get me through the trip and help me keep in touch, pay bills, navigate roads, backup photos etc.

So in a nutshell… I think the gadget count is going to be something like as follows:

  • Eee PC – surf the net, skype, email, blog etc
  • Panasonic Lumix FZ35 – not quite an SLR but awesome zoom… and rather large!
  • Canon IXUS – smaller point and click for when I don’t want to lug the Lumix around
  • iPod – music, also a backup for my photos and any trip notes
  • iPhone – mainly for keeping in touch via SMS
  • Garmin eTrex – don’t want to get lost on a trail, maybe some geocaching too?
  • Kodak PlaySport – take some video of the car drives and places visited so I can show my mum

Between now and next weekend I’m also going to try and sort out my user accounts for various things so I can keep pics and hopefully videos coming through to the site whilst away…

Easy REST service development with Spring 3

So I’ve had the opportunity of late to dabble with Spring 3. From what I had seen before I wasn’t totally sold on the move to annotated controllers but after having used it for a few months I think I’m pretty much a convert to the new approach.

One of the major advantages to this new style is that it makes it dead easy to create RESTful web services. You basically define your controller class and annotate your methods the methods you wish to expose as a REST call with the @RequestMapping annotation. With this annotation you can supply some additional attributes such as the URI pattern you wish to match and what HTTP method applies to the service,

Combined with added support for JSON such as MappingJacksonJsonView and the Jackson JSON libraries one can very quickly whip up a fairly robust REST service.

As a good starting resource the SpringSource blog has a good rundown:

Using Maven and the YUI Compressor plugin to help optimise your site/application performance

So in the last year or so I’ve picked up bits and pieces on how to use automated software build tools. I’ve mainly been using Maven and for the things I’ve had to do so far I’m pretty happy (apart from when the m2eclipse plugin chucks a spaz!).

One cool way in which you can use Maven and the YUI Compressor plugin is to minify and aggregate (if required) your javascript and CSS files at build time.

This will help improve your site/application by minimising round trip times and the number of resource requests that need to be queued due to browser limitations on the number of active concurrent connections.

You utilise the plugin by including the plugin into your pom.xml then defining the configuration that you want applied (e.g. files to include/exclude, aggregation rule etc). The YUI Compresspr plugin site has a couple of examples so refer to it for more info.

One thing I came across though was that if you are using overlays and have resources in the overlay that need to be included in the compression/aggregation you will need to ensure the war is exploded at the start (e.g. process-resources). This is required so that the files are available for running the YUI Compressor plugin on prior to the building of the final war. If you don’t do this step first the overlay is only unpacked during the package phase which is too late as YUI Compressor has already run.

Anyways that’s the tech blog for tonight. Time for sleep…

IE6 the end is nigh…

With the end of IE6 support by Google I’ve decided now is a good time to post about fun with developing web apps that work on IE6. Whilst Firefox is a much superior browser to IE, IE for the most part is okay. Except if you’re developing front end apps that need to operate properly on IE6 as well.

Life then becomes endless fun of trying to work out why things only happen in IE6 but not elsewhere. CSS gone wild, box model fun, random behavior. Caching issues (though that applies to IE5+).

The interesting thing is that IE6 usage is probably actually declining as many small-mid size sites/companies are actually no longer supporting the browser and equally users are using newer versions. But the problem then lies with large corporations who have SOE builds most often which have IE6 installed. If you then think about that, then that’s still quite a lot of people using IE6 who may hit your site during their lunch break.

Food for thought, but it’s slowly getting there…

Firefox “The connection was reset” woes

So a few days ago Firefox on my Mac starting giving me “The connection was reset” everytime I tried to access my website. The odd part was, if I accessed it in Safari it loaded up perfectly fine. After which if I retried in Firefox it started working.

So tonight whilst I’m up late (on-call this week, so have some work to do tonight), I went on a mission to rid myself of the “The connection was reset” error. Disabling/enabling of plugins and resetting of Firefox preferences later it appears the problem is solved. And in the end it looks like all I had to do was clear my cookies.

And now I’m back in Firefox land 🙂

Next post will be on IE woes… the bain of every developer… especially when the dreaded 3 characters of IE6 is mentioned…