Archive for Jul 2009

Counting down the days

I expected this moment a few months ago, but finally it is beginning to hit me: in about three weeks I will be leaving this country for two years (with sparse trips back to check on everybody) :o It is making me a bit restless and uneasy, but in a positive manner.

The preparations are coming along nicely and I sent in my application for "right of residence" yesterday and registerered for the internationals orientation day at the university of Stockholm. I have a roof to sleep under, but we'll have to buy a bed when we arrive. And a bike, and a printer, and ... (the list continues quite a bit)

We are going to see a few friends this weekend in Enschede and say hi, or bye actually. The list of things to do in the Netherlands is gradually slimming into "Packing and leaving"...

Preparing for Agility European Open 2009

It's just a silly game for dogs, but it is pretty cool to watch. This year it is held in the netherlands and I am the one responsible for calculating and printing the results. I had to finish the basics of my new software, because I refuse to patch my old software.

Anyway, time to test the tent again.

Java: equals() and me misusing it (and getting bitten in the bum for it)

I am currently rebuilding the results administration software for Nimble. Instead of using python, this client is built in Java. Why? Well because Swing is the only crossplatform GUI that feels like you are modeling a GUI instead of coding it. And Java is not that bad, if you ignore the fact that you can not do multiple inheritance (I'm problably just spoiled with python).

The system is pretty much eventbased. All calculations are done when needed based on signals from the basic data structures and it does so pretty quick and flawless. Except when I tried to combine results from two (or more) result lists into one.

To give you a clue: results are saved as map from competitor to an achieved score. This is calculated by a hotpluggable calculator (from score sheet to calculated result) and sorted by a Comparator. There is a slight form of misuse here: the Comparator's compareTo-function returns 0 when two results are equals (regardless of the competitor) and the equals-function of the result compares the competitors. So, yes, technically this is a bad idea. But it works in my own sortedset implementation, because now I can name ex aequos.

This worked flawlessly, but began to fault when I wanted to create a combined result (two courses added as a sort of competition). It looked like someone put on the random-bug-generator®. Some results were combined, others only registered one of two results. This was very irritating because a similar thing (teams) already worked, although that was within one result list and this one contained the results of two lists.

What to do? Debug! Debug like your life depends on it! So I hooked everything up and after a morning of manly debugging, I found the problem: misuse of equals and compareTo. When my custom sorter had to resort an item because it signalled it had changed, it removed it from the underlying List and readded it. This worked until now, but I forgot one important thing: the ArrayList responsible uses equals to check if the item is the same... And because I was adding multiple results of the same competitor, it was a question of who came first. Because the competitors were the same, the ArrayList did not care! And in its good right. The fix was as simple as can be: iterate over the list and check for equals and the compareTo.

My bum hurts, but I sure am glad I caught this one. The fault could have been caught earlier if I was not debugging the combined of two team results, with a calculator based on rank :(

Languages and my Mac

Question: why do keyboard shortcuts change if I change the language of the system? It is not like i am connecting a swedish keyboard as well.

I use keyboard shortcuts a lot. Especially in browsers. The command+[ and command+] are very useful, as is the command+Backspace. But when I change my language to Svenska, this becomes command+[something the swedish keyboard has on the same place als [ or ], probably å or ä]. Annoying.

The solution: buy a swedish keyboard, I think. Until then, I'm sticking with Dutch.