Apple announces iPod Nano (and some other stuff)

iPod NanoWell, after much speculation, this morning (AU time) Apple announced a swag of new stuff, including:

  • the quite ludicrously tiny iPod Nano (I reckon I’d lose it)
  • the very expected Motorola ROKR mobile phone, the first to include iTunes (shame it’s a Motorola. I hate Motorolas.)
  • a shiny new version of the iTunes software, featuring parental controls (woo hoo, does this mean no more Lenny Kravitz’s What The F%$# are we saying for my kids?), syncing data with Outlook (at smeggin’ last), playlist and shuffle enhancements
  • some exclusive content to the iTunes store, which therefore means we CAN’T BUY IT IN AUSTRALIA (grumble)

Out to lunch

Windows XP Task managerYou know what really bugs me about Windows and Office sometimes? Sometimes a process will just decided to grab all the CPU and go out to lunch for minutes at a time. I don’t know what it thinks it’s doing — re-indexing its data, re-compiling itself, contacting Mars, something like that. Whatever it is, it’s not paying much attention to what I want it to do.

Outlook just did it. I was in the middle of writing an email. Voom, out to lunch. I managed to save it and exit. And the process kept running till I killed it. WTF? And before you ask, yes, my antivirus and firewall are primed, up-to-date and running. Latest releases, latest service packs of everything. This stuff should be stable.

Annoying, that’s what I call it.

C++: Pointers to member functions

Now, C++ programmers can all program C, to varying degrees of competency. And some know that in C you can store an entire function in a pointer, like so:

int DoTheThingThisWay(double count)
{
...
}

int DoTheThingThatWay(double count)
{
...
}

int (*DoTheThing)( double );  // define the variable
DoTheThing = &DoTheThingThatWay; // set the variable
result = DoTheThing( 2.0 );  // call the function, whatever it is now

Giving you a nifty kinda polymorphism. People who have programmed in C, and needed something like this (say for a state machine) have gone “neat!” and remembered it for later.

So, here we are, later. I’m working in C++ and going to do a state machine. Objects and all. I recall that you can do that polymorphic thing with function pointers, and quickly reconstruct the syntax. Now, with objects I want to point at a function on an object rather than a dumb, lying around knowing nothing about objects function. Easy, let’s just whip that up, I’ve proven how pretty the syntax for calling an arbitary function is, now just to call an arbitary member function.

Half an hour of wrestling with the compiler later, an observation is made along the lines of “everyone does this, just look it up on the web”. Top hit on a Google search for C++ “member function” pointer is http://www.goingware.com/tips/member-pointers.html – which is the right page, and you end up with the call:

result = (objectInstance.*DoTheThing)( 2.0 );

which ain’t so pretty. But you need to do that to provide the hidden this pointer, because you’re working with member functions here, not boring old functions. Add some parameters, store the pointers in an array and before you know it you’ve got

result = (objectInstance.*DoTheThing[FunctionIndex])( 2.0, InitalStringSize, HuffalumpFactor );

which is a long way from DoTheThing(2.0), and I’m not sure what you just got for all that effort. Certainly not readability. Try a pointer to a polymorphic type instead (maybe even a functiod?), and flip the pointer to different objects as you go. Much nicer:

class CThingDoer
{
public:
	virtual int operator(double count);
...
};

class CDoTheThingThisWay : public CThingDoer
{
public:
	virtual int operator(double count);
...
} DoTheThingThisWay

class CDoTheThingThatWay : public CThingDoer
{
public:
	virtual int operator(double count);
...
} DoTheThingThatWay

CThingDoer* DoTheThing;  // define the variable
DoTheThing = &DoTheThingThatWay; // set the variable
result = DoTheThing( 2.0 );  // call the function, whatever it is now

Documenting Oracle databases

We all know what a right PITA it is keeping database documentation up to date. You’ll get a column added to the schema, and make a mental note to update the docs with the intricacies of how it works, then you’ll get distracted by something, never get around to it, then six months later you’ll be trying to remember the details.

Fortunately, the newer versions of Oracle have a rather marvellous commenting feature for tables and columns, so you can document it at the same time as you build it.

To put a comment on a table:

COMMENT ON TABLE xyz IS ‘This is a table for recording xyz usage’

Or on a column

COMMENT ON COLUMN xyz.frequency IS ‘Frequency of xyz usage’

Now, this might be of limited use if you couldn’t get the information out easily. Fortunately, you can. Apart from turning on the comments options in schema browsers such as TOAD, you can get a list of table names with their comments like this:

SELECT t.table_name, t.comments
FROM all_tab_comments t
WHERE t.owner = ‘tableowner’
AND t.comments IS NOT NULL
ORDER BY t.table_name

…and the following will generate a nice list of tables, columns, column types and their comments:

SELECT c.table_name, c.column_name, ac.data_type, ac.data_length, ac.nullable, c.comments
FROM all_col_comments c, all_tab_columns ac
WHERE c.owner = ‘tableowner’ and c.column_name = ac.column_name and c.table_name = ac.table_name
ORDER BY c.table_name, ac.column_id

Mind you, the data length field comes out a bit funny for CLOBs and Numbers. Still, with a little imagination you can write up a quick program to format this output nicely in HTML or WikiText or whatever, for your database documentation.

How open is open?

While Google Talk will use the Jabber protocol, there are concerns over network interopability, with Jabber Australia President (and Geekrant reader) Jeremy Lunn questioning how (and if) Google Talk will work with existing networks.

Meanwhile, the extremely popular but extremely proprietary Skype has opened up… just a teensy bit… with an API to let developers hook into Skype a little more easily. Doesn’t mean other clients will be able to use the Skype protocols, or extend Skype support onto new platforms, mind you.

Annoying Outlook bug

I’m sure this bug has been around for years, possibly back as far as Outlook 98: When reading an email, Ctrl-R is the shortcut for Reply. When writing it, it’s a shortcut to right justify the current paragraph. Even when you’re writing a plain text format mail which has no right justify.

If it was using the same shortcut keys as Word, you could left align it with Ctrl-L, or centre it with Ctrl-E. But neither of these seem to work. Not that it matters greatly, since being plain text, it loses the alignment during transmission.

Mails behaving badly

(Originally written 1997)

There’s no doubt about it, electronic mail is a truly wonderful thing. Using it, I can sit at my desk all day sending trivial messages to my friends, colleagues and family, whether they’re across the world or across the room.

But I have the feeling that some people just don’t quite “get” e-mail. There are people out there who, it seems, don’t quite use it in a logical way. Or at least a way that I think of as logical, and I generally consider myself to be a reasonably logical person, although some of my friends would beg to differ.

This illogical use of e-mail especially seems to be the case in the corporate world, where so often few objections are made to the over-enthusiastic obliteration of time, disk and paper resources.

Take, for example, those people who for no good reason, will not read e-mail on a screen. Yes, there really are people in the world who have to print out all their e-mail onto what remains of a dead tree before they’ll read it. In fact, I knew a guy who, having to clear out his e-mail, printed it all out onto paper. I’m not sure what he did with it – perhaps he hired a truck to take it home, or bought a new filing cabinet to store it all in.

Maybe it’s just me, but doesn’t printing out the mail defeat the purpose somewhat? Once it’s on paper, okay, you can read it, but after it’s filed away somewhere, how are you ever going to find it again? If it’s still in the e-mail system, you can file it, sort it, search for it, reply to it, forward it, and even chop out a bit that contains a really good idea and send it to other people claiming that you thought of it. Not that I’d ever do that, of course.

Another thing that some people do is to send every single message, big or small, important or trivial, as “high priority”. High priority on mail systems doesn’t actually send the message any faster; it simply flags it to the receiver to try to indicate what is important and what isn’t. I’m not sure why these people flag them all high priority, but I’ve seen them do it, and I think it’s almost a subconcious thing. They write their message, and clicking on the high priority icon or button seems like second nature – it’s just something you do before you click Send.

At one job I had, we used an e-mail system that allowed an “extra extra high priority” flag to be set. I got my mail program to automatically bump messages with this flag down a priority point. What could possibly be THAT important? The building burning down? The imminent arrival of the Queen Of England? Chocolate biscuits in the biscuit jar? I don’t think so. News that important never travels by e-mail.

People in corporations also tend to send mail to far too many people. Okay, so there are the times when everybody might need to know about a meeting or something. But sometimes it’s just something that’s come down the line from above, and they feel they have to tell absolutely everybody they can – no matter how irrelevant it is.

Some people feel like they have to make elaborate use of attachments, because they think, for whatever reason, that their message has to be written in Word, or some other application. Most of the time when I get an attached Word document in my mail, I open it and find a message that is completely plain text. No bold or italics, no superscript, no fancy fonts, nothing!

Fact is, these attachments increase astronomically the amount of stuff being flung around the network. You can see the LAN and Mail Administrator guys sweating every time that somebody does something like this.

At one job I was at, someone decided that everybody needed to see a new freeware screensaver that he’d got hold of. Did he put it on a shared drive, then notify people where they could find it? Heck no. He mailed it – all 7 megabytes of it – to everybody. A masterstroke, I’m sure you’ll agree. It clogged up the entire mail system for hours, as I recall.

But the ultimate in irony was a document somebody wrote detailing how to use the mail system in such a way as to avoid overloading it. It was a beautifully prepared masterpiece, with colourful illustrations throughout, and the file came out to about half a megabyte. [At the time, a lot.] The author then sent this to all 200 people in the organisation, once again, clogging up the mail system.

So there you have it, a whole range of ways to misuse your e-mail system and harrass your Mail Administrator. Which will you choose?

Australian postcode data

Writing systems back in the old days, it used to be that occasionally one would need to validate suburb/postcode data, or provide users with a choice of suburbs in a particular postcode, and you used to have to go talk to Australia Post to get hold of that data. It was an administrative hassle, and so updates tended to be infrequent, because really, who has the time?

In these enlightened times, they have it freely available on the web. No registration, no delays, just download. Aussie Post, you rock!

For those dabbling in postcodes worldwide, the Universal Postal Union has an index of post office sites, as well as information on the various postcode formats in use. Jakob Nielsen did a column recently on dealing with international names, addresses and measurements.