Wednesday, March 29, 2006

For sale: Several IDEs, one careful owner

Who will buy Borland's IDE products? My guess is no-one, certainly nobody who's actually interested in the IDE business. Somebody who wants some talented programmers perhaps but why would anyone in their right mind get into the IDE business. Delphi is a great product but it has some serious competition from Visual Studio, which is a loss leader for Microsoft. MS owns .NET and wants everybody to use it and doesn't much care if it makes money on its IDEs. Visual Studio Express is free and is probably good enough for quite a few people. Look at the figures in the UK for Delphi and C# jobs, Delphi is on life support. It is still the best development tool for native Windows desktop applications, but how big is that niche and how fast will it disappear? The other tool that may be of interest to buyers is JBuilder but that is losing out big time to Eclipse, because it's free and good enough. So good luck Borland and good luck Delphi, it was fun...

Friday, March 24, 2006

Beware the ribbon

Jensen Harris has convinced me that the new Office user interface will be lightyears ahead of the current one. But I'm going to make a prediction. I reckon soon we'll see almost every new Windows application adopting the new ribbon UI. But you need to remember that the ribbon has been created to solve a particular problem that Office suffers from. It has hundreds if not thousands of different commands. The average application doesn't have that many and the traditional menu and toolbar is still sufficient. So please spend your time fixing bugs and adding new features rather than adopting a new UI that you don't need.

Tuesday, March 21, 2006

Formatting C# code for a blog

This C# code formatter does the business. Much better than the manual fiddling I was doing before.

Creating thumbnails in ASP.NET

.NET makes some things really easy and creating thumbnail images for a website is one of them. Here's the code I'm using on one of my websites.
 private void CreateThumbnail(string fileName)
 {
   string physicalThumbFileName =
     Path.GetDirectoryName(Page.Request.PhysicalPath) +
     "\\images\\" + fileName + "_thumb.jpg";
   if (!File.Exists(physicalThumbFileName))
   {
     // create thumbnail
     using (Bitmap img = new Bitmap(ImageFileName(fileName)))
     {
       using (Bitmap smaller = new Bitmap(img,
         new Size((img.Width*120)/img.Height, 120)))
       {
         smaller.Save(physicalThumbFileName, ImageFormat.Jpeg);
       }
     }
   }
 }
The thumbnails are created when the page needs them, thus simplifying the upload process, since there's no need for any manual thumbnail creation.

Thursday, March 16, 2006

SEO works, but it shouldn't

It all started about two or three months ago. I got into an email conversation with the webmaster of a website doing a very similar site to the Random Pub Finder. He claimed to be getting about three times as many hits as we were. After looking at his site, I thought the site (to my eyes at least) was no better than ours (and I'm not talking about Beer In The Evening which is clearly better) so I couldn't work out why this was. After talking to a couple of SEO gurus I started making a few changes to the site and over the last couple of weeks or so, we've started to increase our hits. In fact, we are now getting about the same number of hits as he was claiming to get. Now this may not be entirely due to my changes, the search engine algorithms may have changed along with a whole host of other things. But if it is down to the SEO changes, then the search engines have a lot of work to do to optimise their search algorithms. For instance, why should putting the title of the page in a h1 tag make a difference? Surely the search engines should be clever enough to realise any old tag (a div for instance) with the correct style applied will look just the same. Why should h1 be considered as special? So search engines still have a lot to learn. People who put content on the web shouldn't need to know the special magic they need to apply to their pages to get attention. Until SEO gurus are no longer required, search engines will not have perfected their art...

Friday, March 10, 2006

The Road To Guantanamo

I've always followed the career of film director Michael Winterbottom since he went to the same school as me. He directed the great '24 Hour Party People', chronicling the coolest record label of my teeenage years. He also did '9 Songs', the most sexually explicit film to get a certificate in this country, a record that I'm sure will be highlighted in the school's old boys' magazine... Anyway, I saw his latest, 'The Road To Guantanamo', last night and it was great, in a horrendously depressing kind of way. Yes, the 11th of September attacks were horrific but can that excuse the kind of treatment that was handed out to these people (and is still being handed out to the 500 people still there). We protect our democracy by ignoring all the rights that democracy confers on people? Of course it can be said that the film isn't entirely objective, based as it is on the accounts of the inmates. But since the US doesn't seem too keen on letting anybody else in there to see what's really going on, it's all we've got. Required viewing for anybody who still thinks Bush's war on trrrr is worthwhile.

There's a reason they are called exceptions

Whenever you read about exceptions, one of the key points is that exceptions should only be thrown in exceptional circumstances. An example might be when a file the application can't survive without doesn't exist. However I've seen on several occassions now exceptions being used where the particular problem could be expected to happen on a fairly regular basis, if not every time the application runs. A common example can be found when trying to convert a string to an int. In .NET 1.1, int doesn't have a TryParse method so a quick and dirty approach to implementing similar functionality might be as shown here
int val = 0;
try
{
  val = int.Parse(stringVal);
}
catch (FormatException)
{
}
This solution can be fine when stringVal will generally be a valid int, but if it's used when stringVal is often not a valid int (when reading the value from a config file that by default doesn't contain any value for instance), it can become annoying. Why's that then I hear you cry? Just turn off breaking into the debugger when an exception is thrown and all is well. Well perhaps but I always want to break into the debugger when an exception is thrown. Why not just break into the debugger for unhandled exceptions? Because my applications have a global exception handler to do logging etc when an unexpected exception is thrown. So turning off breaking into the debugger when an exception is thrown means I never break into the debugger for any exceptions, which is less than ideal. When developers follow this pattern too often, it can actually become increasingly difficult to ever break into the debugger when an exception is thrown. The IDE option can be become impossible to switch on because the developer is thrown back into the IDE so often. When this happens, we've lost a very useful tool and our debugging becomes much more difficult. Having the option always switched on means we are more likely to find those obscure bugs that only happen once in a blue moon. Another point to make is that this kind of exception handling can affect not only the developers working on your project but developers working on something completely different. I've been working on an ASP.NET project that requires me to run another ASP.NET project at the same time. This other project uses a very similar technique as that shown above which constantly throws me back into the debugger when I'm working on my own project! So how to solve the problem? In the case of the code above, there are probably several solutions, although they will all require some work. Checking for an empty string often solves the problem in 90% of cases, whilst doing some kind of check of the characters in the string would cover the other cases. For most other scenarios where an exception will be thrown, there is almost always a different implementation approach that does not require exceptions.

Wednesday, March 08, 2006

The Doogal Effect

No, no, no, not the effect I have on people, but rather how the release of the film 'Doogal' (based on the drug-fueled children's programme 'The Magic Roundabout') has affected the hits to my home page http://www.doogal.co.uk. See that spike? That was the weekend it was released in the US. And it looks to me that it hasn't been too successful since my hits are already back to normal...

Friday, March 03, 2006

Does PageRank matter?

For some reason, the Random Pub Finder has now got a PageRank of zero. I'm not entirely sure what we've done to upset our lords and masters, but it doesn't seem to be having a negative effect on the number of visitors we are attracting. In fact, visitors are up and most of them are arriving from Google. So I won't take it personally...

The IT Crowd

Written by the same bloke who wrote 'Father Ted', starring Chris Morris and being about IT people, how could 'The IT Crowd' fail to deliver? Well it was reasonably amusing but was never quite the sum of its parts. I think the basic problem was that to hit the mark it would need to make techy jokes that would be lost on the general population. So the fact it is about IT people is kind of irrelevant, it's just another bunch of misfits in an on office sitcom. Saying that, I watched every episode, which is unusual since I don't really watch the telly anymore (unless you count CBeebies). The ending suggested there'll be another series, so perhaps that will allow the characters to grow somewhat.