I read an interesting post from an ex-colleagues blog recently around the subject of unit testing private methods when testing object oriented code. I quote the original post here and my initial response.
“I think a lot of people when getting into unit testing naturally assume (and are told) that typically, a unit is a single method or function within your code, and each unit should have a unit test.
To an extent this is true – until you are presented with what you do with protected or private methods within classes.
There are two camps of thought on this issue.
One (that I completely and utterly disagree with) says that these methods ARE units in their own right, and should be tested as such (using introspection, or language hacks etc). In PHP this can be accomplished by abusing the __call method in your class (to allow a test suite to call protected or private methods on your class).
The second, is that a ‘unit’ is actually a single call to the public interface of your class. The protected and private methods that are called within the class are implementation details and should be allowed to be refactored entirely. Providing the behaviour and the public interface of the class does not change, refactoring does not involve ANY modification to the class itself.
Because the implementation details of a class do not constitute a unit in it’s own right, testing these methods in isolation are therefore incomplete and actually invalid (as they never have the context in which they are used, and even though your code may show 100% lines of code coverage, the branch coverage will always be far from complete).
So – if you’re tempted to create a test for a protected/private method within a class, then you’re moving away from unit tests and into protected your implementation using a unit testing framework.”
My initial response to the article follows:
I would normally say that if you think that a private method requires it’s own unit test then this is a good pointer towards the need to refactor the class – usually pushing the functionality of the private method into it’s own collaborating class.
However that is easier said that done when it comes to working with legacy code. In that situation I would probably refactor the method from private to protected and create tests in the correct package hierarchy (java specific I realise).
I suppose the answer depends on how pragmatic you’re willing to be (and how much code is greenfield development).
Posted in Software | Tagged junit, Software, testing, unit test | Leave a Comment »
Red Dwarf Crew
After 10 years (has it really been that long) away from our screens Red Dwarf is finally making a very welcome re-appearance on UK television over the bank holiday weekend. It looks like some smart exec at channel Dave decided the interest in the recent re-runs was worthy of commissioning some new episodes. In fact there are three new episodes breaking from the traditional single-story-per-episode format by following the same story throughout the trilogy.
It looks like all of the usual suspects are making an appearance in the new episode – titled “Red Dwarf: Back to Earth”- with the addition of, the rather pleasing on the eye, Sophie Winkleman as Rimmer’s nemesis. It looks like there will be a lot more CGI used in these episodes and generally more attention focused on production values – so no more shakey sets and laughable aliens; a shame in a sense, but it may be the crucial factor for hooking a new generation of viewers.
For the fanboys out there (I include myself in there) there are also two special episodes being screened over the weekend:
- The Smeg Ups – A compilation of outtakes from the last 8 series
- The Making of Back to Earth – A behind the scenes look at the making of Back To Earth.
I can’t help but think that the BBC have missed a trick here by not getting in there first and commissioning a new series themselves. That said I don’t really care who’s producing it – I just can’t wait to see it
Posted in Television | Tagged Red Dwarf, Television | 1 Comment »

Nokia N95 8g
I have just spent a very frustrating few hours trying to return my phone to its former glory. I have a Nokia N95 8gig and have been generally happy with the handset for the last year or so, however this evening I wanted to try out the new iPlayer for mobiles service made available from the BBC.
I did some web research and realised that I would need to upgrade my phone to the latest firmware – I’ve not bothered upgrading it since I bought it so this is a new experience for me. Software upgrades can obviously go wrong… as a software professional I’m very well aware of this fact
but I wasn’t too worried about this – the N95 comes with some handy software from Nokia for backing up your whole phone – literally dumping all contacts, messages, images, videos etc off of the handset and onto another device. So before attempting the firmware upgrade I backed up the entire device (takes a while – but could be crucial so I don’t mind waiting).
Right I have the phone backed up, and I have the firmware installer ready to go – there is a warning that the upgrade will wipe the entire phone… but I made a backup right? Ok they’ve gone to the hastle of warning me, so I make another backup – I have two whole phone backups sitting on different drives on my laptop – onwards.
Firmware upgrade runs… takes about 10 minutes…. then the screen goes blank… for a while, but then it came back – Yay! It worked! I now have version 30something of the firmware installed.
This is the point that I remember how annoying the default settings on the N95 are – poor layout and really irritating beeps for every action… but that’s ok – I just need to restore from the backup and I’m done. So I use the handy Nokia PC Suite software, the same one I used to make the backup, and set it going. I wait, and wait a bit more, and a bit more – it takes around 40mins – but eventually it’s done – the phone says it needs to restart – Ok. We’re back in business, the phone comes up and…. er hang on, I have no contacts, or messages, or calendar entries…. Arrrgggghh! My photos are there though, handy.
Long story short, I tried the other backup, I tried the original again, I tried talking to it nicely, I tried shouting… a lot.
Nothing. Arse.
That’s the moment I remember I signed up with the O2 bluebook service a while ago (about a year in fact) – within 10 minutes I’ve logged onto the O2 site, sent the sync software to my phone and grabbed all my contacts back from the web – result! Also all of my text messages are avilable via the site too (if I need to get at them) – great.
So I have my contacts back – well at least as they were a year ago – I’m fairly sure the actual contacts are in the backup file somewhere, which I’ll get around to hacking to bits at some point. Still no calendar entries though…. VERY ANNOYING!
The moral of the story is – Nokia PC Suite backups are crap – O2 Bluebook is great (but you need to sync regularly) – multiple backup technologies are a really good idea – I have no idea when lots of peoples birthdays are anymore.
Posted in Rant, Technology | Tagged backup, bluebook, firmware, O2, Phone | 4 Comments »
On and off over the last couple of years I have been following the trials and tribulations of life on the Ice Roads with Ice Road Truckers and also life in the mountains with the Axemen. These are television shows which follow the working lives of Ice Road drivers in Northern Canada and lumberjacks in Northwestern Oregon.
I wouldn’t say I actually follow these series – but if they happen to be on I’m happy to watch (much to my girlfriends disdain); I think the appeal of these shows for me is getting an insight into the working days of tough guys doing “Real Work” – these guys could get injured, or even killed just going about their daily tasks…Now, don’t get me wrong, software engineering can be pretty frenetic, I almost spilled some warm tea on me (and the keyboard!) the other day – but I’ve never actually felt my life was threatened whilst in the office.

Ice Road Trucker
Ice Road Trucking is essentially about driving very big trucks carrying huge payloads over roads cut into the Canadian icefields over the course of “the season” – at the end of said season the roads start to melt – which is not good for the drivers. Trucking in these conditions is definately a stressful job for the drivers, mainly from an endurance/concentrating for a long time point of view and has some inherent dangers, such as being stranded on the ice road or dropping thorugh the ice. However neither of these risks seems hugley scary to me, if they get stranded they radio for help/wait for the next truck which will be along in a matter of hours; and despite the threat of plunging through the ice – there are support teams out checking the state of the ice so it’s a very calculated risk.
Personally I prefer the Axemen series – this features the workers of various logging companies working in the mountains of Oregon. These guys cut down trees, skip and jump and love to press wild flowers… oh no hang on. Apart from the obvious Monty Python connotations lumberjacking looks like hard work. These guys are charged with felling and retrieving large swathes of seriously big trees from some pretty inhospitable landscapes. There is some sophisticated technology used in the industry but mainly they have to get out there with their chainsaws and get busy.
I enjoy watching both series, but feel that the producers have always been trying to make the programmes into competitions (who can haul the most truckloads, which company shifts the most timber and so on) – I think they’ve missed the point – just seeing what the challenges are and how they do the work is the draw of the show.
The other thing that always irritated me about these shows is that the producers seem to want someone to get injured (or killed) I know it would make good telly but still…
So, based on my interest in the previous shows, I’m intruiged to see Channel 5 advertising the upcoming Oil Riggers series based on the working lives of roughneck oil workers in Texas. I think the producers may have struck lucky (as it were) with picking a very hard messy job with a high chance of injuries…. I’ll be watching with interest.
Posted in Television | Tagged Axemen, Danger, Ice Road Truckers, Television | Leave a Comment »
As an amateur accordion player and fan of folk / jazz music I feel I need to share this site with the world.
Will Pound and Edward Jay are a (new I think) harmonica and accordion duo, they describe their style as:
Folk/jazz crossover. Invigorating, swinging reels.
They produce a very full sound considering there’s only two instruments in the mix – I’m definitely expecting to see these two appearing at the summer festivals in the next couple of years. Check out their demo tracks for a forthcoming album at:
http://www.edwardjay.co.uk/
Owain. (From my sick bed
)
Posted in Music | Tagged Accordion, Folk, Harmonica, Jazz, Music | Leave a Comment »
Everyday, on my way to work, I walk past the new(ish) Q park multistory in central Sheffield. Multistory car parks aren’t generally the most exciting architectural features in a city scape – however the architects took a risk with this one; it’s not to everyones taste – but I certainly respect the architectural vision. It’s become known around Sheffield as the cheesegrater which I think suits it pretty well…

Cheesegrater
It’s distinctive look is leading to it showing up in some interesting places, take a look at this artistic cityscape.
http://smizz.wordpress.com/2009/04/04/imagine/
Posted in Sheffield | Tagged architecture, Sheffield | Leave a Comment »
So, I finally decided to join the great ‘blogosphere’ on the interwebs. I’ve toyed with the idea of maintaining a blog on and off for the past couple of years, but never quite found the motivation to get on and do it. Lots of friends have done the blog thing with varying degrees of success over the years, sadly some of the interesting ones died off due to lack of author time/interest; happily the medium is working very well for various friends living abroad – giving a fantastic insight into their lives.
I regularly find myself having moments in my day where I’ve been thinking about an interesting subject and would like a place to dump my thoughts or a reason to pursue the idea further at a later time – this for me is the real purpose of a blog – a dumping ground for my sporadic thoughts and insights; for my own future reference, but also as a resource for anyone else who happens to be looking for the information. It will also give me a place to get things off my chest (rants a plenty…).
So I’m giving it a go – I’m hoping to create content regularly – probably creating titles/ideas during the day via my phone as ideas occur to me – then expanding into full posts as time allows.
I have an opinion on most things and tend to go off on random tangents fairly easily so I expect to be blogging on a wide variety of topics; in addition to the general flow of consciousness though, I’d imagine the main blog categories will broadly follow my main passions in life:
- Friends, Family and Sheffield – Okay not really a specific blog topic but definately a passion in life
- Music - Folk, Roots, Acoustic, Jazz, Rock, Metal, actually all sorts
- Poker Strategy – I play online mainly – Sit’n'Go and Multi Table Tourneys
- Software Engineering and Architecture – I do it for a living – and I actually enjoy it – okay so I’m a bit of a geek – I have a lot to say on this subject…
I’m sure there will be plenty of other stuff falling between the cracks; I’m always up for feedback so comment away
I have been asked where the blog name came from – very simply I use the name OwZone as an account name on some poker sites and it seems to have stuck as a general online avatar. I may come up with something more witty in the future.
Posted in Blog | Tagged Blogging, Owain | 3 Comments »