Author Archives: Robert Watkins

About Robert Watkins

My name is Robert Watkins. I am a software developer and have been for over 18 years now. I currently work for people, but my opinions here are in no way endorsed by them (which is cool; their opinions aren’t endorsed by me either). My main professional interests are in Java development, using Agile methods, with a historical focus on building web based applications. I’m also a Mac-fan and love my iPhone, which I’m currently learning how to code for. I live and work in Brisbane, Australia, but I grew up in the Northern Territory, and still find Brisbane too cold (after 16 years here). I’m married, with two children and one cat. My politics are socialist in tendency, my religious affiliation is atheist (aka “none of the above”), my attitude is condescending and my moral standing is lying down.

Object equality is context sensitive

Equality is context sensitive. It’s very rarely as cut-and-dried as people think it is.

As a simple example, consider two $5 notes. I think everyone can agree that these notes have the same value – they are both worth $5. But are they equal?

Continue reading

Immutable objects the lazy way

Building properly immutable objects in Java can be annoying, especially if they’ve got a bunch of properties – too many to put into a readable constructor.1

You can implement the Builder pattern, but a lot of the time that just feels like overkill. But you don’t want to put in a bunch of setter methods, because that’s just asking for trouble. So what do you do?

Continue reading

Java, Equality, Mutability

TL;DR version: Don’t implement equals() on mutable objects.

This is a post I’ve been tossing around for a couple of years, ever since a lunchtime debate with a colleague. It’s a simple statement: You shouldn’t implement the equals() method if your object isn’t immutable.1

Continue reading

Example Hadoop Job that reads a cache file loaded from S3

I had all sorts of problems getting my head around how cache files work with Hadoop. Finally, I stumbled across the answer – when you add a cache file (see HadoopMain#48), it’s available to read as a local file inside the mapper (MyMapper#36).

When running in Elastic MapReduce, the file URI can be an S3 file, using either s3://bucket/path or s3n://bucket/path – this may or may not work in other Hadoop implementations, but the general approach would work fine.

See the gist at https://gist.github.com/twasink/8813628

How-To: Grails, GORM and SimpleDB

I went to build a new Grails-based app today, and I wanted to use SimpleDB as a backend (the app is an internal-use administration app, to configure a suite of AWS-deployed apps). So I went looking on how to use GORM with SimpleDB. This turned out to be a non-trivial task, so I thought I’d share the process with everyone.

Continue reading

Building Dependent Maven Projects in Bamboo

For the last year or so, I’ve been using Atlassian’s Bamboo (in the OnDemand variant) for our team’s build server. And, mostly, it’s an awesome tool. Some parts, however, are a little rough around the edges. Building dependent projects is one of them.

Continue reading

Mavericks Upgrade Experience – Apps keep freezing

So I, like a zillion other Apple fanbois, updated to Mavericks yesterday. Yay for free upgrades.

Overall, I’m impressed. It feels faster, I love the proper support for multiple monitors, iBooks on the desktop is a win, and the iCloud keychain works as advertised, with syncing to my phone.

But there’s one big negative – I’ve had multiple episodes of “applications randomly freezing”. When this occurs, the application _that I’m currently using_ just stops. It doesn’t crash, it just pauses. For a few seconds, or a few minutes, then it resumes. I can go use other apps, and they’ll work – or they might pause as well. It’s only been a day, but I’ve had 4 of these episodes so far – once last night shortly after upgrading, which I kind of shrugged off, and then 3 this afternoon, in about a 2 hour period. (Worked fine all morning though).

If I had to guess, I’d say it’s the new memory compression feature – but I had it occur just after a reboot this afternoon, with no other apps open. Then this evening it’s working fine again.

The other likely explanation is a clash with 3rd-party apps – I don’t run that many, but you never know.

In any case, I’m going to be doing a clean install to an external disk to see if it reproduces there – if it doesn’t happen there, then it will be a clean install for the laptop as well this weekend.

If you’ve had issues like that, feel free to leave a comment.

Update: Well, it just happened again. The only observation I can make is that it was while doing a build for the project I’m looking at – it’s quite possible that it was trying to compact memory or move stuff to swap. I wonder if the swap partition is corrupted?

Update the second: As it turns out, my hard disk had started reporting SMART errors the day before I download Mavericks. Bad timing. The freezes were being caused by I/O errors – sure enough, when reading from the swap file (not partition).

Lessons learnt from a bug

This is a rant about a bug report I raised with ExtJS a few weeks ago. That said, I’m using the bug more as a teachable moment than anything else; I’m certainly not trying to bag ExtJS (which I quite like, despite some of its quirks). But this bug does highlight a number of “things done wrong”, which I want to learn from so that I don’t commit the same errors.

(No knowledge of ExtJS is required, and whilst I will describe the details of the bug in depth, the technical issues involved aren’t meant to be the takeaway points)

Continue reading

Giving the ‘hasOne’ association some love

One of the really nice features of ExtJS, to my mind anyway, is the rich model architecture, and how models can be associated with each other. However, the quality can be a bit erratic – certainly, it appears that the HasOne association (which allows a one-to-one relationship) could use some loving, as it isn’t as well developed as the more commonly-used HasMany

Continue reading