Wednesday, January 24, 2007
Tuesday, January 23, 2007
Looking at my Skype client running today, I see there are nearly 9 million people logged on as I write this. Some would say that's enough to show Skype has reached critical mass. But for me the real sign that Skype will soon take over the world is this. My mum uses Skype. I don't mean it's installed on her computer and she ignores it. No, she actually called me up on it the other day. And today she started an instant messaging session with me. So congratulations to Skype for writing a piece of software that is simple enough for a pensioner with techno-fear to use. And congratulations on your impending world domination.
Friday, January 19, 2007
Empty try-catch blocks - "Oh shit, this bit of code fails, I can't be bothered working out what's going on, I'll just catch the exception (and any other exceptions that are ever thrown) and ignore it. Oh and I won't bother putting a comment in the code to explain why I'm catching this particular exception, cos I don't really know why I am."
Well, I guess the thought process is something like that.
Pointless member variables - OK, so you know what a class is and you know what a member variable is, but that doesn't mean every single variable has to be a member variable. It doesn't make your code more object-oriented, it just makes it more complex. If it's only used in one function, then it probably only needs to be declared in that function. In a managed environment, it means the variable goes out of scope earlier and doesn't have to live for the entire life of the class instance. And your code is more maintainable. Although I'm guessing maintainability wasn't the prime concern of whoever wrote this app...
Wednesday, January 17, 2007
Larry Osterman has written a series of posts about software contracts. Well that's what they are meant to be about, but in the end they've been more about the fact that using the PlaySound API asynchronously is really amazingly difficult. One problem is that it's not documented particularly well, but the main problem is the design. The caller allocates some memory, which it must clean up after the sound has finished playing, but if you play it asynchronously you don't get any notification of when it has finished. There's a number of solutions, like kicking off the call synchronously in a separate thread or polling to see when the sound has finished. Larry even went so far as to provide some code to find out how long a WAV file is. Unfortunately some developers 'solve' the problem by just never freeing the memory.
Anyway, this just reminded me of what a complete PITA the Windows API can be, with weird structures and pointers to pointers, and all the docs expecting you to be a C programmer. To be fair, lots of it was designed 15 or more years ago, when PCs were completely different beasts to what they are now but I'm so glad most of my development is now using the .NET Framework. And playing a sound? Actually that was a gaping hole in .NET 1.1 but .NET 2 has the SoundPlayer class. For an async experience, call AsyncLoad, respond to the LoadCompleted event and then call Play and that's it.
Friday, January 12, 2007
Thursday, January 11, 2007
FOR XML RAW - Why on earth would you ever use this in a stored procedure? OK, I can think of one use, when you want to do some kind of XSLT on the stored procedure output to produce some HTML or whatever, but not just so you can treat the output from a stored procedure as an XML document. What's the point? Just traverse the record set using the provided database classes.
Commented out code - If you're using a source control system (and if you're not then you're doomed), why leave commented out code lying around? It's all stored away in the file history. If I do a search for a call to a function, finding lots of commented out code is a waste of my time.
Copy and paste code - It's great to fix a bug in some code, then to find it's been reproduced verbatim in 4 other places in the project...
Monday, January 01, 2007
I always read John Naughton's column in the Observer, I'm not really sure why. Sometimes he has some valid points but he seems so consumed with hatred for Microsoft that he often completely loses the plot. His predictions for 2007 (towards the bottom of this article) seem to me to be some way off the mark.
First up, we'll see the "continued decline of Microsoft". He's been predicting this for so long, he's bound to get it right at some point. Apparently Vista may be the last version of Windows, er why? There's nothing in the article to back up this theory. Also some customers may have to upgrade their hardware to run it. Nothing new there, that has been the case for every new release of Windows but isn't reason enough for it to fail.
Not only that, "The trauma of producing Vista has shaken Microsoft to the core". Really? Sure, it took longer than expected but then so does every bit of major software. He then goes on to say Microsoft has become a middle-aged company, a point that I do agree with. Of course the bigger question is whether Microsoft can continue to use its huge cash reserves and near monopoly position to overcome that particular problem.
He goes on, "the PC is no longer the cornerstone of our information ecology. The network has become the computer". Hmm, unless I'm mistaken every time I connect to the internet I do it through some kind of computer, I can't mind-meld with Google just yet. And most of those computers still run Microsoft software (about 90% of the ones that hit my sites).
Then he moves on to Google's rise. He says its dominance is "underestimated by the usual market-research statistics, which put Google's market-share in the upper forties". I agree with this point, our logs suggest Google is driving about 70-80% of our search traffic. But as the Internet Outsider points out this is not necessarily a good thing. Google is going to find it hard to increase its market share much more, so where will revenue growth come from, since most of its income is based on search?
Finally he moves onto virtualisation technologies being a big thing in 2007. He correctly points out that server farms use up a hell of a lot of resources but I fail to see how virtualisation is going to help here. Having two virtual servers running on one physical server doesn't double the processing power, since each virtual server will essentially have half the processing power of the real server, in fact slightly less due to the overhead of the virtualisation software. Where virtualisation is useful is for running a piece of software on a different OS. So a Mac can run Windows software or vice-versa. I think this could be very useful to a company like Microsoft, since it can forget about backwards compatibility in its operating system, instead letting incompatible software run in its own virtual machine, which in turn may mean their next OS release will be a little easier to get out of the door.