UPCScan 0.7: Where is my stuff?

16. November, 2008

UPCScan 0.7 is released. New features:

  • UPCScan can now find music CDs
  • If UPCScan can’t find something on Amazon, it will still create an entry which you can then edit to fill in the details.
  • Entries can be deleted.
  • I’ve added lending information so you can quickly figure out who your new “ex-friends” should be.
  • I’m working on a series/issue information system to make it more simple to complete your collection. With this version, you’ll need to edit the database directly to add series/issue information but the user interface can already display this data.
  • I’m working on a feature to create an OpenOffice document with the locations. This would allow you to print this out and then scan the locations in as you scan your collection to tell UPCScan under which location to file the items. If you can’t wait, then you can use the barcode.py script to generate PNG images with barcodes which you can import in OpenOffice to achieve the same effect.

Download: upcscan-0.7.tar.gz (26,921 Bytes, MD5)

Testing the Impossible: User Dialogs

11. November, 2008

How do you test a user dialog like “Do you really want to quit?”

This code usually looks like this:

    public void quit () {
        if (!MessageDialog.ask (getShell(),
            "Really quit?",
            "Do you really want to quit?"

        ... quit ...

The solution is simple:

    public void quit () {
        if (askToQuit ())

        ... quit ...

    /** For tests */
    protected boolean askToQuit () {
        ... ask your question here ...

In test cases, you can now extend the class, and override askToQuit:

    public boolean askToQuitWasCalled = false;
    public boolean askToQuitResult = true;

    protected boolean askToQuit () {
        askToQuitWasCalled = true;
        return askToQuitResult;

Now, you can find out if the question would be asked and you can verify that the code behaves correctly depending on the answer. Tests that just want to quit won’t need to do anything special to get the desired behavior.

The same applies to more complex dialogs: Refactor them to put their data into an intermediate structure which you can mock during the tests. That means to copy the data if the dialog is a black box but that’s a small price to be paid for being able to test modal user dialogs.

Lesson: You don’t want to test the dialog, you want to test whether it is opened at the right place, under the right circumstances and if the result is processes correctly.

I Have Nothing to Hide … I Think

10. November, 2008

So it has happened again. Someone put a nice web site online and when it came to pick and chose between security and comfort, guess who won. Alas, those who do as you shouldn’t still server as a bad example. What has happened?

DHL, a German parcel delivery service, offers a web site where you can track where your brand new gadget is now so you can guess how long it will take until you rip the wrapping off it. That good.

Not so good is that all customers of DHL get the same default password.

Bad is that DHL reuses the tracking numbers after roughly six months (depending on the amount of parcels that go through the system; if there are less, you can look further into the past).

Really bad is that part of DHL’s tracking number of fixed. It’s based on the DHL customer number. That’s not you, this “customer” is the guy or company you ordered from (DHL renders a service for them).

So this leaves us with a convenient way to check who else has ordered anything from those that shop.

Now imagine you ordered something innocent … oh, maybe porn or “adult toys” or something from company B which is the arch enemy of company A which incidentally pays your wage. All of a sudden, a couple of innocent bits of information have turned ugly.

Whenever you put something out to the world, step away for a few moments from your dreams how much good someone could do with your service and think how much bad someone could do with it. And if you can’t think of anything, you should be very, very worried.