Rant: Using Error Codes in User Messages

In short: DON’T!

What in the world was Apple thinking when you try to upgrade/register/sync your iPhone/iPod and you get “Error: -19″ or “Error: -20″?? What good does this do any one? How am I supposed to fix the problem if I don’t know what the problem is? Isn’t Apple the king of user-friendliness?

When you write software, you should use good error messages. You should use good exceptions. You should use descriptive values.

Granted, some things the user cannot fix. Telling the user the database connection was lost on a web application does very little good for the user. You can however tell the user that an error that was not their fault occurred. At least then I know I can come back and try again later.

Luckily, after rebooting my iPhone I was able to install the recent software update. This may not have been the problem, but certainly Apple could have notified me that I should attempt rebooting.

In any case, be nice to your damn users!

Using EclEmma to Write Better Unit Tests

If you don’t already write unit tests you should be. (Hey, why aren’t you writing unit tests?) Unit testing has so many benefits and the upfront developer cost to write some unit tests can pay huge dividends later when you aren’t spending time debugging broken code nor attempting to save face due to clueless mistakes. You can also use them as a contract to the expectations of your implementations.

So, assuming you have some unit tests, how useful are they if they don’t test everything? At some level you will want to have a good idea that you’re testing everything. (NOTE: I mean everything really important. Writing perfect 100% coverage like this would likely be too expensive for the entire codebase.) This is where Emma comes in (and more importantly for us, EclEmma, an Eclipse plugin for Emma). Emma is a code coverage tool which lets you visual which parts of your code get executed during some execution (regular or JUnit).

Lets walk through using EclEmma to ensure that we have adequate testing being done. Lets test the following two classes.
More on Using EclEmma to Write Better Unit Tests

Consistent Hashing

I don’t normally post links to other sites, but this is a great article about consistent hashing that greatly simplifies the explanation.