Tuesday, June 27, 2006

How to dodge questions

Update (2006-07-12): I do not endorse this technique. I hate it (see the "It simply drives me nuts" bit). I am merely documenting it to expose those people who use it.

This is what I call the "CSI" (not the TV show) technique - Change, Stall, Intimidate:

First, change the topic: "I think that's a very good question. It certainly raises some interesting issues related to what I said before."

Second, stall by talking about what you said before, for about 2 minutes.

Third, intimidate the person who posed the question by asking "Does that answer your question?" By this time, the audience is so bored that that person will not have the guts to pursure further questioning, in order to save the audience from listening to junk for another 2 minutes. However, if that person is somehow not discouraged and persists, say "Now as I said before" and repeat the "stall" step. Alternatively, s/he would have forgotten his/her original question by now.

It simply drives me nuts when I'm in a meeting and the speaker uses this technique when they clearly have no clue (I'll blog on other techniques used to say nothing, some other day). But from what I can see, this works like a charm. And now you know how to do it and sound intelligent too - great for those "strategic" business meetings that we all inevitably find ourselves in.

Exams over

Yay! The highlight was an invigilator saying:

"For those whose don't know the date, today is the 26th of June 2002".

Wednesday, June 21, 2006


Should a null QString be identical to an empty QString? Is there sanity in having undefined vs empty strings in PERL? What about null vs empty strings in Java?

It's those annoying cases in programming that always require extra checks. In SQL, it's NULL. Comparisons with it almost always return "unknown" (which is usually interpreted as false). Worse still, "NOT unknown" is still "unknown". So when one writes:

CHECK (attribute = 0 OR attribute = 1)

SQL will happily allow the insertion of a row with a NULL "attribute". So this must be rewritten as:

CHECK (attribute IS NOT NULL AND (attribute = 0 OR attribute = 1))

See, I just dropped a few marks for this tiny mistake...

Oh, and BTW, Oracle morphs empty strings into NULLs, which is the pinnacle of insane behaviour.

Poseidon - Movie Review

Watched Poseidon on Monday with a friend from high school. I normally watch movies in the evenings on weekends so it was rather surprising how few people there are on a Monday night (could be counted on 2 hands) even though this cinema is in Sydney city.

It's essentially Titanic except they're trapped in an upside-down ship and it isn't boring (it probably won't win any film awards as a result :)).

Quite a thriller as a bunch of the characters break away from the main group to save themselves, as the water rises inside the ship and fiery debris is abound. They drop one by one. I say "a bunch of characters" because character development is fairly poor, there are too many main characters (think "Copland" but not as bad), some of the actors look the same and could have gotten away with playing another character for a bit without anyone noticing.

For black humour, the kid resembles the one from "The Sixth Sense" so just after the ship has tipped over, and with encouragement from a former fireman, he jumps down from where he's hanging, I could just imagine him making the observation "I see dead people".

Nevertheless, the acting of all the characters is exceptional and the life-death decisions they make are rather gripping. The camera work is excellent in building up and maintaining the tension. The pan around the ship at the start is stunning (and could probably only have been done via computer graphics).

Now for plot problems:
1. The elderly man mentions something to his business partners (?) about someone regrettably leaving and that they know the consequences of this. He seems to try to get in contact with this mystery man (but later throws his mobile phone into the ocean). It is implied that this person leaving is going to result in some disaster but this seems to have no bearing on the plot (unless it was disaster). Anyone know what's going on?

2. The captain orders the ship to do a starboard flank. However, the "rogue wave" is shown to be approaching from the right of the ship. So the captain actually turned the ship into the wave!

3. The area with the main dance floor of the ship is claimed to be airtight and the air bubble will keep the ship afloat. But air must be pulled from the outside otherwise, even in normal situations, air would run out quickly and everyone would die of carbon dioxide poisoning (exhaled breath). Therefore, it can't be airtight.

Summing up, an exceptional thriller for people who appreciate simple entertainment. On my Prime - Spiderman 1/2 - Batman Begins scale, where Prime = hopelessly boring, Spiderman = ok-good and Batman Begins = exceptional, it scores somewhere between Spiderman and Batman.

Monday, June 19, 2006

Oral exam on software engineering ethics, fun

There were 3 questions:

1. Free choice

2. One out of nine possible questions based on seminars. At the examination, three are chosen randomly and the student gets to pick one out of those three.

3. One out of eight possible questions based on lectures. Chosen similarly to 2.

Pigeonhole principle comes in handy here: If one wants to prepare for question 2 fully, they only need to prepare 9 - 3 + 1 possible answers. Similarly for 3. Now, pigeonhole principle seemed to me like a stupidly obvious theorem when it was taught but since it's saved me some work, at least now I can appreciate it.

So what questions did I end up picking? Well for the free choice, I chose a rather controversial topic on copylefting software. I won't start another flamewar except to say that I BSD license everything these days so you know my position. It was rather rushed and unfortunately, I don't think the markers were convinced.

The second was the technical problems with the Therac 25.

The third was about how patents might stifle innovation and aren't suitable for software. A key example I used was Eolas' patent claim against Microsoft: "Distributed hypermedia method for automatically invoking external application providing interaction and display of embedded objects within a hypermedia document", where Microsoft lost $US521 million, for implementing something fundamental to web browsers. Imagine if people went around patenting "1+1" and suing school children for practising maths. You certainly can't get away with that but with software, somehow people have.

Friday, June 09, 2006


KolourPaint places widgets on top of a KToolBar for its "Colour Box" (a great abuse of KToolBar, I know - I'll be looking at fixing this). Unfortunately, in Qt4, right clicking on a colour patch (e.g. the transparent or green, circled in red below):

no longer selects the background colour - it brings up the toolbar popup menu instead:

(neat "Lock Toolbars" option BTW)

It turns out that implementing QWidget::mousePressEvent() no longer stops your parent from receiving the right mouse press that would invoke contextMenuEvent(). Spotting the new contextMenuPolicy, I figured that I would just set my children widgets to Qt::NoContextMenu ("the widget does not feature a context menu"). Doesn't work.

They way I got around it was to get the children to eat/accept() the contextMenuEvent(). Another undocumented, subtle change between Qt3 and 4...

In the meantime, I have started porting KolourPaint4 to a new "kpPainter" that abstracts away QPainter (not committed to SVN yet). Rectangles now work and are no longer 1 pixel higher and wider than they should be. Eventually, this abstraction will allow me to dump the Qt graphics routines for a better graphics library.

C++ class member function pointers

This prints -7:

#include <stdio.h>

struct Moo
int func () const { return -value; }
int value;

int main ()
Moo m; m.value = 7;

int (Moo::*funcPtr) () const = &Moo::func;
printf ("%d\n", (m.*funcPtr) ());
return 0;

Gotta love the "int (Moo::*) ()" syntax - pointer to any member function of class "Moo" as long as it returns an "int" an accepts nothing.

And of course, "(m.*funcPtr) ()", which invokes the pointed-to function with "m" as "this".

Wednesday, June 07, 2006

The fun of Politics

Don't buy joke books - read the Australian House of Representatives Hansard instead:


"Mr ABBOTT (Warringah -- Leader of the House)
(12.34 pm) -- I move:
That that snivelling grub over there be not further heard.


Mr Abbott -- If I have offended grubs, I withdraw


Mr Swan interjecting --

The DEPUTY SPEAKER -- The member for Lilley
walks a fine line by calling the Deputy Speaker an idiot.

Mr Crean interjecting --

The DEPUTY SPEAKER -- The member for
Hotham walks a fine line by clapping."

I don't understand how politicians can get anything done admist these antics.