Wednesday, February 21, 2007

Sorting in a DataGrid

There doesn't seem to be a lot of information around on getting sorting in a WinForms DataGrid to work with custom collections. So I've done the hard work for you and here it is. First I wrote a sorting class, hopefully generic enough to sort pretty much any kind of simple data types (if your collection contains other objects you'll probably need to update this somewhat).

  internal class Comparer : IComparer
  {
    private PropertyDescriptor sortProperty;
    private ListSortDirection sortDirection;
    public Comparer(PropertyDescriptor sortProperty, ListSortDirection sortDirection)
    {
      this.sortProperty = sortProperty;
      this.sortDirection = sortDirection;
    }

    #region IComparer Members

    public int Compare(object x, object y)
    {      
      Type propType = sortProperty.PropertyType;
      int sort = 0;
      if (propType == typeof(string))
        sort = string.Compare((string)sortProperty.GetValue(x), (string)sortProperty.GetValue(y));
      else if (propType == typeof(DateTime))
        sort = DateTime.Compare((DateTime)sortProperty.GetValue(x), (DateTime)sortProperty.GetValue(y));
      else if (propType.IsEnum)
        sort = (int)sortProperty.GetValue(x) - (int)sortProperty.GetValue(y);
      else if (propType == typeof(int))
        sort = (int)sortProperty.GetValue(x) - (int)sortProperty.GetValue(y);
      else if (propType == typeof(Type))
        sort = string.Compare(sortProperty.GetValue(x).ToString(), sortProperty.GetValue(y).ToString());
      else if (propType == typeof(bool))
        sort = string.Compare(sortProperty.GetValue(x).ToString(), sortProperty.GetValue(y).ToString());
      else
        throw new NotSupportedException();

      if (sortDirection == ListSortDirection.Descending)
        sort = -sort;

      return sort;
    }

    #endregion
  }

Then I had to implement the IBindingList interface. Actually most of the IBindingList interface is redundant (makes me wonder why it wasn't broken down into a few smaller interfaces, ISortList, ISearchList etc), so here are the bits that are different to the stubs provided by Visual Studio.

    void IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction)
    {
      sortProperty = property;
      sortDirection = direction;
      objectList.Sort(new Comparer(sortProperty, sortDirection));
    }

    private PropertyDescriptor sortProperty;
    PropertyDescriptor IBindingList.SortProperty
    {
      get
      {
        return sortProperty;
      }
    }

    bool IBindingList.SupportsSorting
    {
      get
      {
        return true;
      }
    }

    bool IBindingList.IsSorted
    {
      get
      {
        return (sortProperty != null);
      }
    }

    void IBindingList.RemoveSort()
    {
      sortProperty = null;
    }

    private ListSortDirection sortDirection;
    ListSortDirection IBindingList.SortDirection
    {
      get
      {
        return sortDirection;
      }
    }

objectList is my internal ArrayList that contains the collection of objects I'm interested in.

I'm not entirely happy with this solution. I have a lot of collection classes and each one has this same bit of code in it, which always smells a bit bad to me. At some point I might try to create a base class that encapsulates this functionality but it doesn't look too straightforward, since IBindingList requires IList, ICollection and IEnumerable implementations as well... 

Tuesday, February 20, 2007

Metastorm Resources

As well as getting hits from people searching for remedies to their medical problems with their bell ends (hint: go and see a doctor), I also get a few hits from people trying to track down information about Metastorm e-Work/BPM. So here's a short list of potentially useful sites.

Process Mapping - OK, it's my employer so I'm biased but it has some useful stuff. If you develop with e-Work be sure to grab a copy of the Procedure Documenter Designer add-in, which not only automatically documents your procedure but also checks for problems in your procedure that are missed by the Designer's validation.

Process Mapping Forums - OK, it's my employer again but if you're looking for an online community to discuss e-Work issues, this is definitely the best place to go. The official Metastorm newsgroups are like a ghost town, the once great eworkdev.org is now a site about Chinese babies and the only other one I'm aware of, eworkhelp.org, seems to be dying due to lack of people and increasing spam.

FreeFlow - Hmm, alright, this is mine... But if you want to integrate .NET and e-Work, these class libraries may well help. There's also a replacement for the abysmal Metastorm admin tools, which I use everyday (can't remember when I actually used the official tools) 

BRD - Thought I better add something that hasn't got anything to do with me just to make me look a little bit impartial. BRD produce the Swift client, an alternative web-based client, that provides quite a few features not available in the standard Metastorm client.

If you have any other links, let me know and I'll update this list. 

Thursday, February 15, 2007

DataGrid copy to clipboard

Here's some code I knocked together to copy the contents of a WinForms DataGrid to the clipboard. Probably won't work for all possible data sources but it was good enough for my needs. 

    public void CopyToClipboard()
    {
      StringBuilder builder = new StringBuilder();
      for (int i = 0; i < ts.GridColumnStyles.Count; i++)
      {
        if (i > 0)
          builder.Append("\t");
        builder.Append(ts.GridColumnStyles[i].HeaderText);
      }
      builder.Append(Environment.NewLine);

      CurrencyManager manager = (CurrencyManager)BindingContext[DataSource];

      if (DataSource is DataTable)
      {
        DataTable dt = (DataTable)DataSource;
        foreach(DataRowView r in manager.List)
        {
          for (int i = 0; i < dt.Columns.Count; i++)
          {
            if (i > 0)
              builder.Append("\t");
            builder.Append(r[i].ToString());
          }
          builder.Append(Environment.NewLine);
        }
      }
      else if (DataSource is IList)
      {
        for (int i = 0; i < manager.List.Count; i++)
        {
          object item = manager.List[i];
          Type objectType = item.GetType();
          for (int j = 0; j < ts.GridColumnStyles.Count; j++)
          {
            string colName = ts.GridColumnStyles[j].MappingName;
            PropertyInfo propInfo = objectType.GetProperty(colName);
            object propertyValue = propInfo.GetValue(item, null);
            if (j > 0)
              builder.Append("\t");
            builder.Append(propertyValue.ToString());
          }
          builder.Append(Environment.NewLine);
        }
      }
      else
        throw new NotSupportedException();

      Clipboard.SetDataObject(builder.ToString(), true);
    }

Saturday, February 10, 2007

Resizing columns to fit in a DataGrid

I wanted to automatically set the width of columns in a WinForms DataGrid to something sensible based on the contents (using .NET 1.1 for a number of reasons). I've seen the solution to this in a couple of places but they didn't work for me because I'm using a grid that inherits from DataGrid and adds a few helper methods. So here's what I've come up with.

    public void AutosizeColumns()
    {
      Type t = GetType();
      t = t.BaseType;
      MethodInfo m = t.GetMethod("ColAutoResize", BindingFlags.Instance  BindingFlags.NonPublic);

      for (int i = 0; (i < TableStyles[0].GridColumnStyles.Count); i++)
      {
        m.Invoke(this, new object[]{i});
      }
    }

Sunday, February 04, 2007

The CSS media attribute

I was going to write about this some time ago and never got round to it but Jeff Atwood covers it much better than I could ever hope to. Another reason I thought I'd highlight this is after a conversation with one of our clients who'd paid a company to write an ActiveX control to produce printer friendly versions of web pages. There really wasn't any need, it's trivially simple to produce a stylesheet for printer-friendly output, generally all you need to do is hide some of your headers and menus etc. Even with my pathetic CSS skills I managed to create one for the Random Pub Finder.

On the other hand I'm not so sure about the use of a handheld stylesheet though. I did one of these for the Random Pub Finder as well, but as far as I can see we never get any hits from handheld devices. Also, I may be wrong but I think quite a few handheld devices actually ignore the handheld stylesheet and just render websites using the standard stylesheet. This is probably due to the lack of websites that actually provide a handheld stylesheet, meaning any handheld device needs to be able to cope with full-size pages anyway. And finally, it's a right pain testing your site against the huge number of devices out there, particularly as the emulators always seem to be a pain to set up.

Friday, February 02, 2007

Installing a .NET assembly with COM interop

I've written a .NET 1.1 assembly that needs to register for COM interop. I've been using the Visual Studio 2003 installer to build my installer, because it's generally good enough for what I'm doing and it's free. OK, it's not exactly free, but who buys Visual Studio for the installer bits?

Anyway, the installer had been working fine by setting the Register property of the assembly to vsdrpCOM but when I went to test the installer I'd built today after some changes to the assembly it wasn't getting registered. Oddly the install completed and didn't suggest there was a problem but the registry was empty. I could register the assembly using regasm, but that doesn't seem like such a good solution for customers!

So after a not so quick Google later I came across this newsgroup posting (near the bottom) which showed a solution to the problem. And it worked. Problem solved. What I particularly like about this solution is that I'm now back in control of registering my assemblies, rather than being in the hands of the installer's black box implementation, which I've had weird problems with before.

Thursday, February 01, 2007

So what is a bell end?

I noticed that a search for what's a bell end on Google brings up this site at number one, so I thought I better answer the question.

So here goes, bell end refers to the end of a man's, er, manhood. The name came about because it's shaped somewhat like a bell (go on have a quick check, nobody's looking) and it is, in fact, the end. It's a simple as that, although it's often used as something of a derogatory term, where someone might say "he's such a bell end".   

The obvious follow on question is why on earth I chose it as my blog name? And the answer to that is I'm not entirely sure. I've certainly been called it quite a few times (due to the surname) and couldn't think of anything more appropriate at the time.

BlogSpot not very well

Lots of people getting a bX-vjhbsj error, as am I. So you probably can't see this...

Wednesday, January 24, 2007

Snow


This morning we woke to a world of white. As is usual with snow in London it didn't last very long. It had all melted by lunchtime. So here's the photographic evidence.

Tuesday, January 23, 2007

Skype has reached critical mass

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

Things annoying me today

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

Why you should be using the .NET Framework

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

IE7 Uptake

According to the IE blog, they reckon 25% of web users are now using IE7. I'm seeing about 20% on my sites, but I bow to their bigger sampling space. Even so, it looks like I was somewhat over-optimistic with my prediction.

Thursday, January 11, 2007

Things annoying me today

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

John Naughton's predictions for 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.

Saturday, December 30, 2006

Deadpool 2007

It's that time of the year again when I have to submit my list for the Deadpool game. If you're one of the celebrities on this list, don't panic. I haven't come close to winning in the several years it's been running. I always keep the same list except for any additions, a strategy that has been spectacularly unsuccessful. 

  • David Rockefeller, 1915, Very rich, very old
  • Denis Healey, 1917, Old Labour
  • Billy Graham, 1918, time to meet his maker
  • John Glenn, 1921, It could be one space mission too many
  • Hugh Hefner, 1926, Viagra overdose? 
  • Boris Yeltsin, 1931, A popular choice, with good reason
  • Larry Hagman, 1931, Already on his second liver
  • Alex Higgins, 1949, Snooker player with throat cancer, apparently
  • Shane MacGowan, 1957, Singer with a soon to be non-functioning liver
  • Holly Johnson, 1960, Frankie Goes To AIDS Clinic
  • Monday, December 18, 2006

    Displaying a tick mark in HTML

    This afternoon's challenge was to get a tick mark to appear in a HTML file. Not too taxing I thought. I'd already done it, using the HTML entity &#10003;. But this didn't properly in all browsers. I initially thought the problem was some kind of encoding problem but it seems that unfortunately it's one of those HTML things that works in 'modern' browsers but doesn't seem to work in IE6 (this ✓ should be a tick mark, if you're one of the lucky ones). Given that most people are still using IE6, it's not really an ideal solution.

    So what to do? I thought I'd search for a fairy common font that had a tick mark available. WingDings does and although it's a Windows font, I thought it would be available on enough computers to suit my needs. Unfortunately, as this page shows, FireFox doesn't display WingDings fonts at all, even when they are installed on the computer. Most odd, although it seems that this is how browsers should work...

    You may be asking why I didn't plump for the simplest solution, displaying an image? Unfortunately I'm generating a web page on the fly on the user's PC and I don't want to be generating extra images if I can avoid it. Life could get very complicated if they already have a file with the same name on their PC. I guess they wouldn't appreciate me overwriting it.

    So my not very neat solution was to use a standard checkbox, <input type="checkbox" disabled checked>, . This wouldn't be too bad if I could apply some styling to it to make it look less like a checkbox, but CSS for a checkbox is ignored so I'm not very happy with the resulting output. If anybody knows of a better solution, let me know.

    Addendum - Since quite a few people are finding this page, you might be interested in the follow-up posts, which have a potentially better soluton to this problem

    Sunday, December 17, 2006

    Another way to get more hits to your site

    I guess like most sites the Random Pub Finder gets most of its hit through Google searches. But a drunken chat with a friend led to another way to drive more traffic to the site. I've uploaded all the pub images to Flickr and added links to the reviews on the site. So far results have not been spectacular but it means we have deep links into some of our pages so their PageRank should improve. And who knows, it might work for you.

    Thursday, December 14, 2006

    Setting a display from: address using CDONTS

    Since it took me so long to find the answer to this problem I thought I'd post it here (and also so I don't need to look it up again). Not sure if this applicable to other ways of programmatically sending email but I guess it probably is. To show a friendly display name when setting the From: address of an email using CDONTS just use the following syntax -

    (Test address)<test@test.com>

    Wednesday, December 13, 2006

    Testing, testing

    Just testing out Windows Live Writer with the new version of Blogger... And it works, hurrah!

    Tuesday, December 12, 2006

    Reading embedded resources in C#

    Reading embedded resources in .NET isn't particularly hard but since I always forget how to do it, I thought I'd write it down for my own benefit. 

    First thing to do is set the Build Action property of the file you want to embed to 'Embedded Resource'. Next download my Resource Explorer from

    http://www.doogal.co.uk/ResourceExplorer.php

    After building the assembly, inspect it with this little utility to find out the name of the resource. If you're clever you can probably work out the resource name for yourself but I'm lazy and/or stupid (depends which day it is).

    Finally, the code to read it is something like this.

    Assembly assem = GetType().Assembly;   
    using (Stream stream = assem.GetManifestResourceStream("resource name"))
    {
      stream.Position = 0;
      // read data from stream

    Thursday, December 07, 2006

    Visual Studio 2003 on Vista

    OK, I should have known better. I'd read about the lack of support for Visual Studio 2003 on Vista, but then I read another article claiming all I needed to do was turn off UAC. I was planning on doing that anyway, since UAC seems like the biggest PITA of all time (and I seem to avoid any kind of virus/malware without it). So I went ahead and installed Vista. And Visual Studio 2003 falls over all the fecking time... I can't edit any of the code-behind files in one of my websites.

    Fingers crossed Microsoft will release a version of VS2003 that actually works on Vista. If it means turning off UAC, I'm cool with that. Their excuse is that they want to use their scant(!) resources on the next version of Visual Studio. Even if I believe they haven't got the resources to get VS2003 to run on Vista, can't they slow down a bit? .NET 1.1 does most of the things I want to do pretty well, .NET 2.0 adds a few nice things, but nothing mind blowing, I don't even care about .NET 3.0 yet, so I care even less about the next version. The thing is I have a job to do and that job is to get working stuff to clients, they don't care what version of .NET I'm using and certainly don't want to be paying for me to upgrade to the latest and greatest version every other day... 

    Currently listening to 'Nothing' by 'No-one' from the album 'My soundcard doesn't work on Vista'

    Monday, December 04, 2006

    Reflector insanity

    I spent a couple of days at a conference last week, which was fun. What did I learn? A few things, but the weirdest thing I learned was about Reflector's crazy behaviour. Often when Reflector starts up it informs you there is a new update available. Generally I'll let it do its thing and download the update. But it turns out if you don't download the update when you exit Reflector it deletes itself from your hard disk...

    Wednesday, November 29, 2006

    Liking Vista, mostly

    I've got no sound, Visual Studio 2003 is a bit unsure of its new environment, it took me an hour to fix up my source control installation due to Vista clobbering file permissions, UAC is crap (I have turned it off and turned off the warning telling me to turn it back on) and SonicWall VPN Client doesn't work but... Vista is actually pretty good. Search works quickly for the first time ever in Windows (and searches emails as well!), the new UI is actually quite beautiful (something that could never be said about the XP Fisher-Price look), IIS 7 is a damn fine upgrade (although it took a while to get my ASP.NET 1.1 apps up and running) and performance seems to be pretty much the same as XP, which is quite remarkable given all the visual additions and extra services that have been added.

    No doubt the Mac did it better two years ago but the Mac doesn't have any apps I need. My Mac OSX box sits unloved in the corner with nothing to do...

    Sunday, November 26, 2006

    Vista headaches

    I'm a bit of a fool when it comes to new software, if I can get a copy of something cool for free I'll probably install it. So, since the company I work for now has an MSDN license I thought I'd give Vista a spin.

    So I pretty much ignored the warnings the installer gave me about the problems I might have and went ahead and installed it. And the warnings were pretty much spot on. I now have no sound and I can't play videos. I have no idea why but I guess it's a driver problem. Hopefully Dell will fix the problem PDQ because sound is kind of important for me since I use Skype all the time...

    Other than that Vista seems to work fine. I'm not sure at this point whether the upgrade was worth it, nothing has jumped out at me as an aboslutely must have feature.

    Saturday, November 18, 2006

    FireFox and IE differences

    Often when I'm reading up on support for particular HTML or CSS features, I'll see something along the lines of "Most modern browsers support this feature, Internet Explorer doesn't". A loose translation of this could be "if you use this feature it won't work for 80% of your users".

    I do most of my testing in IE then go over to FireFox to make sure it looks OK and probably because of this it always seems to be the other way round, FireFox doesn't support a lot of stuff that IE does.

    FireFox doesn't have a way to render text vertically. OK, there's no official way to do this, so IE has come up with it's own CSS attribute, but I'm kind of surprised that FireFox hasn't come up with some way of doing it, it seems like quite a common thing to want to do.

    Another problem is hiding and showing rows in a table. FireFox kind of supports using 'display:block' but the row gets taller and taller with each hide and show. So I have to use 'display:table-row', which doesn't work in IE. Not sure which is standards-compliant but 'display:block' seems like the more consistent approach.    

    Friday, November 17, 2006

    XSLT not completely insane

    I've played with XSLT before and never quite got to grips with it, but over the last few days I've finally got a basic understanding of what it's all about. It still seems like it was designed by somebody who was an XML/HTML addict and could only think in terms of tags when developing a programming language. Like the old saying goes, when the only tool you have is a hammer, every job looks like a nail. But the thing is if you have an XML document and you want to transform it to some other flavour of XML or HTML then XSLT is a fine choice. I'm still not sure if my XSLT is any good or not, I've not seen any coding standards for it anywhere. Should I be splitting things out into multiple templates? Should I be doing anything in particular to make my XSLT more maintainable? Dunnow. But I've got 1000 lines of it and it produces quite a nice HTML document so that's good enough for me at the moment.

    Currently listening to Love Less by New Order from the album Technique

    Wednesday, November 15, 2006

    Well done Ken

    Chelsea Tractors are going to be hit by another tax soon, as the London Congestion Charge will be increased to £25 for band G vehicles. Well done Ken!

    Tuesday, November 14, 2006

    Breaking news: No-one buys Borland's IDE tools

    However they try to spin it, it's fairly obvious that Borland were unable to find a buyer for their IDE business. So my prediction was right. Is it good or bad news for Delphi and their other tools? It doesn't look great but at least they can hopefully stand on their own two feet and won't have their income sucked away to finance the ALM business.

    Currently listening to The Only One by Billy Bragg from the album Workers Playtime

    Crude awakening - Peak Oil

    Found a couple of interesting videos about peak oil and some of the possible solutions

    Part 1

    Part 2

    Saturday, November 04, 2006

    IE7 take-up

    IE7 hasn't been released as part of Windows Update yet, but its usage is up to 6% of all IE users on the Random Pub Finder. Saying that, FireFox 2 is being used by 38% of all FireFox users. I reckon that is down to the techy nature of most FireFox users. Funnily enough 20% of our visitors are now using FireFox, which is pretty astounding. I'd guess we've had quite a few techy people visit recently due to the coverage we've had.

    Thursday, November 02, 2006

    Build it and they will come

    After five years, the Random Pub Finder has finally become an overnight success. Google seems to have started re-indexing pages, although there's still a random nature to its indexing. We were up to 300 pages indexed, now we're back down to about 150. But the main reason for the sudden surge in traffic has been appearing at Programmable Web. Thanks to that, we've been covered on a couple of other sites. We've never had so many hits.

    Now I'm actually getting traffic here as well, thanks to this post. Seems I'm one of the top results on Google if you search for directmailchat. Clearly I'm not the only one suffering from this spam.

    Tuesday, October 31, 2006

    I am a sex god

    I've been getting a lot of emails like this recently

    Hi,
    Hope I am not writing to wrong address. I am naice, pretty looaking girl. I am planning on visiting your town this month. Can we meet each other in person? Message me back at qzyv@directmailchat.info

    Today was different, it came from somebody called Johnathan...

    Makes you wonder how successful these kind of spams are, with a To: list of several people, a From: address that doesn't match the address they've asked me to reply to, a load of spelling mistakes and apparently coming from a girl with a boy's name.

    Monday, October 30, 2006

    Hurrah for Richmond Council

    Richmond Council are introducing increased parking charges for high-polluting vehicles. This brought all the usual rubbish from the 4x4 drivers. Lets go through the points one by one.

    4x4s are efficient

    If your 4x4 is efficient then it won't be charged very highly. The charge is based on CO2 emissions, not car size.

    I need a big car, I've got 4 kids

    Presumably it was your decision to have 4 kids. Having kids is expensive, you have to feed and clothe them, house them. You wouldn't expect these to be subsidised would you? It's not like we have a shortage of kids on the planet.

    Climate change is just a theory

    Even though the vast majority of scientists agree that temperatures are rising and we are at least partly to blame, this line still gets trotted out. Can someone explain why I've still got bees flying round my garden at the end of October?  This isn't normal. But let's assume climate change isn't in fact happening. Cars produce pollution at a local level, are noisy and generally reduce quality of life, particularly in cities like London where there isn't enough space to accomodate them. Not only that, but fossil fuels will run out, some time. So it seems like a good idea to reduce our dependence on them.

    It's undemocratic

    The motoring dinosaur Jeremy Clarkson claimed the whole thing is undemocratic. How's that then? The council were voted for by the people of Richmond. If the residents don't like it, they can vote them out again.

    What I like about this scheme is that it shows we can do something about climate change at the local level, we don't have to wait for the government or, even worse, the international community to do something. Since we live in the neighbouring borough and our council is also run by the Lib-Dems, I'm going to be lobbying them to introduce the same scheme.

    Currently listening to Have A Day / Celebratory by The Polyphonic Spree from the album The Beginning Stages Of... [UK]

    Friday, October 27, 2006

    iTunes and Windows Live Writer love-in

    For the past few months I've been using my Toshiba Gigabeat to listen to music in my office, but something has been bugging me about it for a while. The random play functionality is completely whacked out. It seems to be random based on the artist, so if you've got one track by an artist, that artist will get as much coverage as an artist with 100 tracks.

    So I decided to move my MP3 collection on to my new PC and use iTunes instead. That in itself was a bit of a pain. The Gigabeat converts MP3s into a file with a SAT extension so you can't just copy them back across, since nothing but the Gigabeat knows what a SAT file is. But if you plug it in right, Windows recognises it as a media player and knows what to do with the files and does the conversion on the fly. All seems a bit odd really, but I could now listen to my MP3s through iTunes.

    And now I've found a very nice plugin (well two actually) that lets you insert the track you're currently listening to into your blog post. Perhaps it should be called 'Completely Pointless Vanity Plug-In' but I like it.

    Couple of things to note. The Apple website doesn't seem to be correct when it tells you where to put plug-ins for iTunes to pick up, it says they should go under 'My Documents' somewhere but I had to put it in C:\Program Files\iTunes\Plug-ins.

    The Live Writer plug-in goes in C:\Program Files\Windows Live Writer\Plugins but by default the plug-in will insert 'Nothing playing', you need to update the HTML template to something like <P>Currently listening to %t% by %a% from the album %al%</P> to get it to work.

    Currently listening to Carrion by British Sea Power from the album The Decline of British Sea Power

    Tuesday, October 24, 2006

    Disabling the Dell malware

    When I purchased my new PC it came with a whole host of crapware that I didn't want. Most of this could be removed but one piece of software remained, an extension for IE that brought up a Dell search page whenever a website failed to load. I've never tried to get rid of this because it's never caused too much harm but today it began interfering with my work so it was time to get rid of it. IE7 makes it pretty easy to disable pointless or dodgy add-ins. If you have the same problem as me, go to Tools/Manage Add-ons/Enable or Disable Add-ons and disable CBrowserHelperObject object. No more 'helpful' Dell search page, yippee!

    Sunday, October 22, 2006

    Google Sitemaps improvements

    I'm not sure when these changes were introduced to Google Sitemaps but there are now some useful little graphs that tell you how often your site is crawled and how responsive your site is. Go to the Diagnostic tab and click on 'Crawl Rate' to see it. You can even tell Google to crawl more often if you like (not sure if their bot will actually take any notice of this request or not). Overall, I like it a lot.

    Saturday, October 21, 2006

    So how quickly will IE7 be adopted?

    Apparently IE7 will be distrbuted as part of Windows Update, so I wonder how quickly it will replace IE6? Looking at the stats for the Random Pub Finder, of the 85% who used Internet Explorer to visit this month, 4% were using IE7. I'm guessing it will take about 2 months for the majority of IE users to have switched. Lets wait and see... 

    Thursday, October 19, 2006

    Somebody listened

    OK, probably not to me, but the silly error message no longer appears in the final released version of IE 7

    Wednesday, October 18, 2006

    IE7 Stupidity

    Internet Explorer 7 is mostly a good experience. Yeh, it's ripped off some of Firefox's features, but that's what Microsoft do well.

    But what on earth is this dialog box about? I tried to paste into a field in Google Maps and it popped up. I understand that Microsoft is getting a little paranoid about security these days, but of course I want to allow the webpage to access my clipboard, I just hit CTRL-V! Oddly enough this doesn't happen on all websites, so perhaps Google Maps is doing some odd scripting when I do a paste. Who knows, but please someone fix it!

    Exciting new website

    In their ongoing attempts at SEO, BetterDeal have got a new site (New Car Showroom) and they want some inbound links. Where better to get them than from here, with my huge number of visitors and massive PageRank?

    Monday, October 09, 2006

    Hello World for ZX Spectrum lovers

    When I was a young lad, there was nothing I liked more than going down to my local Dixons after school and typing my very own Hello World application into the nearest ZX Spectrum. But the Hello World apps I see today just don't match up to the beauty and elegance of that original version, so I've written one for C#

    using System;
    
    namespace HelloWorld
    {
        class App
        {
            [STAThread]
            static void Main(string[] args)
            {
                 line10: Console.WriteLine("Doogal is cool!");
                 line20: goto line10;
            }
        }
    }

    Who says goto is evil? I think I might adopt this style for all my applications...

    Sunday, October 08, 2006

    Bid on my birthday present

    My brother has given everybody the opportunity to bid on my birthday present. Looks like he'll send it to me, even if somebody else outbids me, but any proceeds go to charity, so get bidding!

    Thursday, October 05, 2006

    Google have cocked up again

    It looks like Google has cocked up its data update again. The PageRank updates it started a few days ago look like they are being rolled back, so the Random Pub Finder is back to PR 0. More worryingly, if I do a site: search, all URLs bar three are now shown as supplemental. But If I do a search for particular keywords, other pages on the site are returned and aren't marked as supplemental. Go figure.

    Wednesday, October 04, 2006

    How to have a reasonably successful website

    I can't pretend to know a lot about making a website a huge success, none of the sites I've been involved with have been massively successful, but I've kind of worked out how to get a reasonable number of visitors to a site without any kind of massive outlay. Here are a few of my thoughts.

    Don't spend a lot of cash

    Websites are pretty cheap to run. Even if your website is your business, you can probably keep it running with no visitors and no income for a pretty long time. Blowing any money you do have on advertising before you're even sure your site is up to scratch is a sure fire recipe for disaster. Better to get just a few visitors in who'll give you a good idea if you're heading in the rifgr direction and you can fix any problems you have before too many people spot them.

    I think advertising in the old media is pretty much a waste, it's very expensive and it's hard to see if it's been a success. You can advertise using AdWords for next to nothing, giving you the chance to see if it works at all and also trying out different advertising approaches.

    Don't ignore SEO

    Google is fond of saying that you should optimise for the end user, not the search engine. I can understand where they are coming from but essentially this is pretty much untrue. If end users can't find your site, whether the site has been optimised for users or not is pretty much irrelevant, they'll never see it. Chances are search engines will be the biggest source of traffic to your site, so of course you need to optimise for them. I managed to triple the number of visitors to the Random Pub Finder just by applying some simple SEO, all completely above board and not impacting on the end user at all. I found this free download a very useful read.

    Design isn't too important

    There are many examples of butt ugly sites being pretty damn successful (craigslist being the most obvious example) and plenty of examples of beautiful sites that have crashed and burned (boo.com comes immediately to mind). The fact is if the idea behind your site is appealling, people will come back. If the idea doesn't appeal, it doesn't matter how good looking it is, people will go elsewhere.

    One company I worked for redesigned their site about 4 times in one year, in an attempt to get more conversions. I've no idea how much they spent in total but the effect on conversions was pretty minimal, so it was pretty much wasted cash. Every redesign brought a host of new problems that needed fixing, along with pages stored in search engines that no longer existed. Not only that but time spent on those redesigns could have been spent refining and improving what was already there.

    Keep focussed

    I've never really stuck to this advice (this site covers whatever I can be arsed to write about) but if you want to get people coming back to your site it sure helps if your site covers a single topic, or a few related topics.

    Iterate and watch

    I come from a software development background and I've always practised a kind of iterative development technique. And I use the same approach when developing websites. Make a small change, see if it works, move on. Unlike software development, when developing websites the 'see if it works' stage doesn't just mean 'make sure it runs OK'. it also requires looking to see how it has affected traffic, so the iterative cycle can be somewhat longer. and to see if it works, you need to have some data. The cheapest tools (i.e free) for this job are Google Analytics and Google Sitemaps, which tell you how many visitors you're getting and what keywords are driving them there, along with heaps of other information.

    Take advantage of free advertising

    There are plenty of opportunities to get more hits on your site that cost nothing. When I post to a forum and I'm given the opportunity to provide a URL I always do. Of course, posting randomly to forums just to get a link to your site is generally considered as spam and will likely cause more harm than good. Sites like Technorati and digg can drag in more readers and directories related to your site can help pull in yet more eyeballs.

    Wait, and wait some more

    I have no knowledge of the search engine algorithms but I'm pretty sure, all other things being equal, a site that has been around for 5 years will rank higher than one that's been around for 1 month. So if you just hang around doing nothing, your site should start to get some more hits. I've never really done anything to get hits to doogal.co.uk, but I now get about 200 visitors a week.

    Monday, October 02, 2006

    PageRank update

    I've just noticed that Google seems to have updated PageRanks across my various sites. And finally The Random Pub Finder has got some PageRank! It's been PR0 for about a year, now we are up to PR3. My home page and this blog are both up, wahey!

    Wednesday, September 27, 2006

    The Great Australian Survey are spammers

    I signed up with the Great Australian Survey (www<dot>aussiesurveys<dot>com<dot>au) to see where BetterDeal were mentioned and I started getting the usual crappy offers from them. Kind of expected that, but the emails had an unsubscribe link at the bottom. I've clicked on that twice now and ticked the relevant boxes on their site but I'm still getting the emails. Either they are completely incompetent (why on earth are they sending emails to a .co.uk address anyway?) or they are spammers.

    Thursday, September 21, 2006

    Working from home is different

    Working from home is certainly different to the usual office environment. In most offices I've worked in I didn't have a window to look out of, never mind looking out to see a fox, who seems to have taken a liking to lying on my shed's roof in the afternoon sun.

    Wednesday, September 20, 2006

    The changing face of spam

    The Random Pub Finder has been getting a lot of spam reviews recently. This isn't a big deal, the reviews go straight to my inbox and don't appear on the site until I put them there, but the weird thing is the content of these spams. Many of them are bacon-related. Here's an example

    "a rasher ( and reland), or a slice ( orth merica). raditionally the skin is left on the cut and is known as bacon rind. indless bacon, however, is quite common. n the"

    I just can't work out what on earth they are trying to achieve.

    On the other hand, email spam seems to be getting more sophisticated. I'm now getting quite a lot of spam emails that contain a single image offering whatever penny stocks I really need to buy, followed by some text that isn't related and is obviously being added to get through the spam filters. How can we ever defeat that kind of spam?

    Sunday, September 17, 2006

    Saturday, September 16, 2006

    Dell vs HP

    I've got a new computer from Dell and now my HP DeskJet 5550 doesn't work. Funnily enough the reason I've got the printer is because my de-facto mother-in-law bought a Dell computer and the printer wouldn't work for her either. Who's to blame for this I wonder? I've been fiddling around with it for most of the day and can't get it to work. I can print out the HP test page but any other page refuses to do very much except throw out a blank sheet of paper. Based on my experiences with the new computer that have been mostly positive (except for the shitload of rubbish software it came installed with) I'm going to blame Hewlett Packard.

    Do you ever need to do a complete rewrite?

    Joel Spolsky's article about rewriting software has always struck me as a very well reasoned argument for never rewriting software from scratch. He mainly talks about Netscape's attempt to rewrite their browser from scratch. You might claim this was a reasonable success in some respects since it led to FireFox, which now has a pretty decent share of the browser market (about 10% I guess). But compared to the market share Navigator had before they started their rewrite it is still pretty miniscule. Of course they may well have lost a lot of that market share anyway, since MS was installing their browser on every new machine that was sold. But MS stopped developing Internet Explorer after they achieved almost complete ownership of the browser market, which gave FireFox a chance to gain ground. So basically we'll never know what would have happened if Netscape had continued with their old codebase.  

    So I was somewhat disturbed to find out one of my previous employers had decided to rewrite one part of the software product they sell. I could say who it is but I don't really want to have them getting their legal dogs onto me. I worked on this part of the system for over six years and it is pretty large (with third party code it's over 500,000 lines of code) and pretty central to the whole product. It is written in Delphi and the rewrite will be in C#. As a developer, you always want to work on the latest cool technology and always think the legacy code you're working on is a complete mess, so I'm sure they are happy to be involved on a green field project like this but I'd hope the people in charge would have a very good reason for wanting a complete rewrite, but frankly I can only think of one. It's probably getting increasingly difficult to get hold of good Delphi developers. The market is shrinking and from what I can see the good Delphi developers are moving onto other things, like C#.

    I've heard they have a team of five people working on this and it is planned to be done in a year. OK, here's my guess on how long it will take. Whilst I worked there, there were probably on average about 2 developers working on this bit of the system. I'm guessing it continued with the same level of manpower after I left. When I started they already had a working product, if a little rough round the edges, so say that took 2 man years. I started in '98, 8 years ago, so we have another 16 man years of work, 18 in total. Divide that by 5 people and we have about 3.5 years to write a piece of software that has the same functionality as what they currently have... Lets hope they have five really good developers...

    As an aside, it has to be pointed out you'd need to have very good reasons to want to get to C# anyway, whether through a rewrite or a migration. Whatever people say, Delphi is still a fine choice for Win32 desktop applications. OK, it is missing some of the nicer features of .NET like reflection and the availability of 3rd party controls is drying up but it still produces small, quick native apps. And if you have a stack of Delphi code, throwing it away is a very expensive thing to do.

    But is there any other way? I thought about this when I worked at the company. Like any developer I wanted to move onto new technology so I had a long hard think about how to get from the Delphi codebase we had to C#. One choice was Delphi for .NET, but this looked like a pretty painful route, especially with the number of 3rd party controls (many no longer supported) we were using. My though in the end was the best route to take would be to componentise what we had using COM. OK, this wouldn't really be a step forward, more a step sideways, but once you've got those components in place you could start to replace each bit piece by piece.

    But I hear you saying, that would take even longer, since you still need to rewrite each bit and you have the overhead of separating them into COM components in the first place. And you'd have to use that horrible COM Interop stuff as well. All true, but the major advantage of this approach is that you will always have an application in a state that is ready to ship, or very close at least. A complete rewrite means there will be a very long period of time when you can't ship anything at all, unless you want to add new features to the old codebase at the same time as adding them to the new codebase, which will be even more expensive and painful.

    So I wish them good luck with their development. I really do hope it works out, because my livelihood now depends on their software...

    Wednesday, September 13, 2006

    ASP.NET State Service crashes on shutdown

    Am I the only person to suffer from this? Can't find anything on the web but whenever I shut down my machine the ASP.NET State Service crashes. I thought it was caused by my old machine but my new machine has exactly the same problem. No big issue since the machine still shuts down but odd that nobody else seems to be suffering with it.

    Tuesday, September 05, 2006

    We are all doomed

    There are still people who claim climate change is only a theory, just like there are people who think that evolution may not be correct or the Holocaust never happened, but there seems to be pretty much total consensus amongst scientists that it is happening and we are to blame. But even if climate change isn't happening, there is another problem awaiting us, which certainly can't be ignored. Fossil fuels will run out and, more importantly, we will pass the maximum level of production, possibly quite soon. And once that happens, if demand continues to increase, the price will rise pretty quickly. And oil is fairly fundamental to our economy, due to the amount used to produce and transport goods. I was pretty stunned when I noticed some apples in our local supermarket were being imported from New Zealand...

    But running out of oil was bound to happen at some point in the future but unfortunately we have completely failed to address the issue, so we head into an uncertain future where "the Thames estuary is the most vulnerable place in northern Europe to major storm surges", which could affect me fairly directly.

    I'd always thought that computers would help out here. I'm doing my part by working from home but unfortunately it turns out that growth of the Internet is actually sucking even more power from the grid, so perhaps that isn't part of the solution either. So, as the post title says, we are all doomed.

    Monday, September 04, 2006

    100th Post

    So somehow I have managed to reach 100 posts on this blog. I was presuming that by the time I reached this point I would be a major web celebrity with millions of readers and I'd be rich beyond my wildest dreams through the adverts on-site. But it hasn't quite panned out that way and I have to say I'm disappointed in you all. Where are you and why are you choosing to read some boring old shite rather than the riveting stuff here? I feel like this kid...

    Friday, September 01, 2006

    The Apostrophe Protection Society

    Some people seem to have a real problem understanding where apostrophes should and shouldn't be placed so I was pleased to find the Apostrophe Protection Society, who were set up "with the specific aim of preserving the correct use of this currently much abused punctuation mark in all forms of text written in the English language". Their site explains all the rules which are generally pretty easy to understand, except for the occasional edge case.

    Thursday, August 31, 2006

    Metastorm e-Work 7 and DEP

    I've already written about Metastorm e-Work 7, so I was quite excited when I got hold of the CD and immediately started to install it on a test machine. That is until I read the Installation Guide which said "Before attempting to install Metastorm BPM ensure the Data Execution Prevention (DEP) feature is disabled.". Er, excuse me? I read on and was dumbfounded to see that I had to turn off DEP for the whole machine before I could install version 7. I ignored the advice and tried to install anyway but the Installation guide was telling the truth. I couldn't install because DEP was enabled.

    What is DEP and why should you worry? Applications on your computer have a code section and a data section. Executable code is contained within the code section and any other data required by the application is within the data section. Most applications will only ever execute code from the code section but until recently nothing stopped you from writing an application that ran code from the data section. This could be potentially useful if you need to write self-modifying code, but there is a very small minority of applications that would ever need to do this. In fact the overwhelming number of applications that do execute code in the data section are viruses, trojans and other malware. So Microsoft have recently introduced DEP that will stop applications executing code in the data section. There are two flavours of DEP, software and hardware. The hardware version only runs on the most recent processors but other than that I'm not sure of the differences. But one thing is for sure, DEP is a good thing! It is just one line of protection for your PC but an important one. Disabling it is asking for trouble.

    So why does e-Work 7 require me to disable DEP? To be blunt, the software has a bug. Clearly Metastorm thought disabling DEP was an easier option than fixing the bug. What I do find odd is the fact that it is possible to disable DEP on a per-application basis, so I don't understand why they didn't go down this route. I would certainly consider installing the software if this was how it was set up. As it is, e-Work 7 will be remaining on my shelf. If I was Metastorm I'd be somewhat concerned about the possibilities of a lawsuit caused by a server being compromised due to DEP being disabled...

    Wednesday, August 30, 2006

    Delphi the best tool for .NET? Er, no

    Nick Hodges is doing a fine job of evangelizing Delphi which makes me think Delphi may have some kind of future but in his latest post, he suggests that Delphi is the best choice for .NET development. Delphi is certainly still a great choice for native Win32 application development but it just can't compete in the .NET world. There still isn't a version that supports .NET 2 so Delphi developers don't get to play with all the new features. Delphi is always likely to be playing catch-up in this respect. Also, almost all .NET code examples on the web are in C# or VB.NET which would make life more difficult for anyone developing in Delphi for .NET.

    There are situations where using Delphi in a .NET environment makes sense. If you have a large Delphi code base that you want to get to .NET, rewriting in C# or VB.NET isn't likely to be the most cost-effective solution. If for some reason you need to target Win32 and .NET, Delphi would also be a good solution, in fact probably the only solution.

    Finally, looking round at new applications coming out, we are now starting to see .NET managed desktop apps appearing. How many of them are written in Delphi? I don't know of one. In the world of ASP.NET I guess it's harder to know what language is being used for the development but I'd guess the vast majority of them are in C# or VB.NET. Compare this to the world of Win32 development where there are quite a few high quality apps being actively developed in Delphi and it's clear that .NET developers also don't think Delphi is the best tool for the job. 

    Sunday, August 27, 2006

    Getting into MySql with PHP

    Our host for the Random Pub Finder has been providing MySql integration for a while. I've been holding off using it for a while because I was thinking of converting the RPF to ASP.NET. But I eventually decided that was going to be too much like hard work and would break any links in. OK, I could probably do some URL rewriting to get round that but again it seemed like a lot of bother and PHP does pretty much everything we need.

    Anyway, I signed up for the MySql integration and I've been pleasantly surprised with how good the phpMyAdmin web interface is. RPF has been running off several text files for the last five years so I had to make quite a few changes to our code but getting the data in to MySql was pretty straightforward (phpMyAdmin will suck in any kind of delimited text file). Setting up phpMyAdmin on my local machine was pretty straightforward. OK, it's not MS easy, but then this is a free bit of software developed by people in their spare time. So I had to tweak a few text config files to get it working and I couldn't get it to play with PHP 5 but PHP 4 is fine for our needs. And now it's working I'm presuming I won't need to touch it again.

    Updating the RPF live site is now much simpler, I just insert a new row in a table and a new pub appears on the site. Previously I had to update one of our text files and email it to myself, run to my other half's laptop, download the email and FTP it to our host via a phone modem, because they won't let me connect to the FTP site via our broadband connection. I guess that's because their business model is based on getting revenue from phone calls... 

    So, in conclusion, a thumbs up for PHP, MySql and phpMyAdmin. Perhaps I'll stop being an MS fanboy and become a open-source zealot. Time to grow a beard...

    Programmable Web

    Just found this site, which looks like a useful resource for knocking together Web 2.0 (God I hate that term) mashups (God I hate that term)

    Thursday, August 24, 2006

    What is the point of Second Life?

    Apparently it's very popular with the young uns but I'm failing to understand why. I've been wandering around for a while and there just doesn't seem a great deal to do, except check out some butt ugly buildings. If I want to live in a fantasy world I want to be able to do some fantastic things, like wield big guns and blow up things, not just socialise...

    Worst of all, I seem to have to download a new version every time I log in. 

    Wednesday, August 23, 2006

    Google Maps and the Random Pub Finder

    OK, I got bored waiting for a response to my queries about ripping off people's code so the Random Pub Finder London Map has gone live. Trying not to be too big headed, I think it's superb. None of it would have been possible without phpcoord and overplot. If programming is an art form then the old adage 'good artists borrow, but great artists steal' must be true...

    Solving the Google Maps performance problem

    Google Maps has a nice API to create your own map interfaces on a website. Unfortunately it has some serious performances problems when you add a large number of markers. In my case, I have about 500 markers and both IE and Firefox grind to a halt on my page. I've seen various suggested solutions, the most common being to reduce the number of markers by only showing one marker when there are several clustered together when zoomed out. I'm sure that would work but I wasn't too keen on the idea because it just sounded like too much work. Fortunately somebody has come up with a nice solution that works well for me. thanks to the wonderful open source nature of the web, I can happily rip off his code. Just need to get approval from him before I show off my new page to the world...

    Sunday, August 20, 2006

    Pompous rock star is hypocrite shocker

    This is old news but apparently Chris Martin, lead singer of Coldplay and a man known for mouthing off incessantly about environmental issues, owns a BMW X5. This Chelsea Tractor will be doing approximately 15mpg as he drives near his central London home. Nice one!

    Thursday, August 17, 2006

    More Windows Live Writer

    A comment to my previous post from Spike Washburn (of the Windows Live Writer team no less!) suggests image uploading won't be supported until Blogger improve their API, which is a shame. So Blogger, get your finger out! And apologies if it appeared that I was suggesting Windows Live Writer deliberately wasn't supporting image uploads to Blogger.

    A couple of other points about Writer. First, I'm very pleased to see it is a managed application. Great to see MS dogfooding the .NET Framework and proving it's possible to produce professional apps using WinForms. 

    Second, it's great to see developers from MS responding to blog posts from little old me. Fact is I'm a Z-list blogger that no-one reads but I've had two lots of feedback from MS people. That kind of communication will really help build a good feeling towards MS in the IT community.

    And yes, I'm using Writer to write this post.

    Windows Live Writer

    Just playing around with Windows Live Writer and it's mostly pretty cool. The first problem I've encountered is the lack of image support on Blogger, which is pretty much a showstopper. Odd really, because Blogger does support images, but I guess this is a beta...

    More fun with <noscript> tags

    The guys at BetterDeal wanted to know why their website didn't rank as highly as some of their competitors. Short answer is inbound links, which seems to be the prime ranking decider used by Google. To illustrate I did a link:www<dot>carbroker<dot>com<dot>au search (replace the <dot> with ., don't want them getting anymore inbound links), which is one of their competitors. The odd thing was that one of their inbound links came from a penis enlargement site. Penis enlargement doesn't have a lot to do with new cars, other than the obvious psychological enlargement for men who buy big red Ferraris. Looking at the source of the penis site (purely for research of course) showed up the reason. The link was hidden away in a <noscript> tag. Car Broker are also the guys who have <noscript>betterdeal</noscript> hidden away in one of their pages slagging off reverse auctions, which is why they rank pretty highly for a search on "BetterDeal reverse auction". Although Google know about this, they haven't done anything about it and their algorithm still doesn't seem to handle <noscript> tags too well...

    Tuesday, August 08, 2006

    Borland goes Turbo

    So Borland have revived their Turbo range of products. The originals came out before I did any real programming (the ZX Spectrum probably doesn't count) so I don't how revolutionary they were at the time. But the question remains whether this will help revive Borland/DevCo's fortunes. Microsoft moved the goalposts when it released its Visual Studio Express range for free, and Borland had no choice but to respond by releasing free versions of its own development tools. But free and academic versions don't bring in a lot of revenue and although they may drag people in Borland's direction who may start to pay for products later, that's likely to be a long term effect. For Microsoft, development tools are a loss leader, they don't care if they make money so long as they keep people using Windows. For Borland/DevCo it's essential these products make money or else they're out of business. On another note, although the Delphi community seem to be very excited about these new developments, will the rest of the world care? The people who Borland seem to be aiming for, i.e. new developers, probably don't have a clue what the Turbo range was and because of that the new website probably doesn't look retro and nostalgic, it just looks naff. Saying all that, I am pleased to see Borland/DevCo making some positive moves to sell their development tools, it certainly makes a change from the last few years.

    Monday, August 07, 2006

    Land Rover's misplaced marketing

    Today I received a letter from Land Rover, offering me the chance the test drive their latest model. Whilst I'm sure it would be fun, there's no way I'd ever think about buying a new Land Rover so why are they sending it to me? I'm not sure where they got my address from but I think they need to do some better filtering of their mailing lists. First, I can't afford a new Land Rover. Second, I live in the middle of the largest city in the UK, why on earth would I want to buy a car that has 'authentic off-road ability'? Third, I'm concerned about this environment thing. Why would I want to buy a car with a 4.2 litre engine that does approximately 13 miles to the gallon with CO2 emissions of 374g/km??? It's nice to see their letter was printed on paper from sustainable forests, but perhaps they need to sort out their massive gas guzzling machines as well? To be fair, the original Land Rover is a design classic and before I realised the environmental damage owning one would do, it was near the top of my list of cars to own. Any way, the real reason for this post is to point out there is a way to stop receiving all this junk mail. MPS Online claim that they will stop unsolicited mail coming to your door. I only signed up a week or so ago so it hasn't stopped yet but fingers crossed it will do soon.

    Sunday, August 06, 2006

    Richmond Park

    Truth be told I don't much like London. When hearing this, people will often trot out the usual Samuel Johnson line, but the fact is Johnson lived in an entirely different London to the one I live in now. But one of the great parts of London has to be Richmond Park (although some people will claim this isn't really part of London, because it's in zone 5). When cycling around its huge area, I can almost forget that I'm anywhere near the busy, unfriendly city I know.

    Thursday, August 03, 2006

    Lots of new posts

    Just copied across the interesting posts from my old blog, enjoy!

    DesignerSerializationVisibility attribute

    When writing .NET components, often you don't want properties to appear in the Property Window. This is well documented and is achieved with the following [Browsable(false)] But what you also generally want to happen is for the property not to get persisted to the form in the InitializeComponent method. Unfortunately the Browsable attribute doesn't do this part of the job, but thanks to one of my colleagues, this is how you achieve that. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] Perhaps there are occasions where these would be used separately but I can't think when they'd be

    Use the tool, tool part 8

    OK I lied, the last post wasn't my last post on .NET tools, there's one more. NAnt is a handy tool for automating builds. Although it's possible to drive Visual Studio.NET from the command-line, NAnt does lots of other things, like running your unit tests and zipping up files etc etc via an XML configuration file. I haven't used it a great deal myself, but I will be shortly.

    Use the tool, tool part 7

    Right I have one more .NET tool to recommend and then I'm done. And that is FxCop. This will analyse your assemblies and tell you all the problems it finds. And my word, does it find a lot of things. The fact is a lot of the rules are just plain anal, but it still finds stuff that could be a problem. And whats more, you can add your own rules, although I can't say I've ever done this.

    Use the tool, tool part 6

    Documentation is a right pain the behind, or at least it used to be. C# simplifies it a great deal by providing in-built support for it. XML tags can be added to your source code as you go along, so that 2 week task at the end of the project can be avoided. So once you've tagged all your code, what next? Download NDoc and you can generate help files just like the ones in Visual Studio. If it hadn't been for this tool, I'd probably never have got round to releasing a little project of my own into the wild. Another useful tool for generating documentation is GhostDoc, which automatically generates a first attempt at the documentation based on parameter names and method names. It doesn't always get it right, but it's often good enough.

    Use the tool, tool part 5

    I haven't covered the most useful .NET tool yet, the wonderful Reflector. If you haven't got this yet, download it now. One of the great things about Delphi development was the fact that Borland provides the source to the whole component library, which really helps tracking down weird bugs and work out how their stuff works. Microsoft don't provide the source to the .NET Framework, but with Reflector it doesn't matter. It can reverse-engineer any .NET assembly and you can see how it works. Yes, some class library developers obfuscate their libraries, but Microsoft don't and that's the most important library. Reflector also has several add-ins that do useful things like reverse-engineering a whole assembly which is useful for, er, more nefarious deeds. There are also plug-ins to generate Delphi code and other languages. So, as I said before, if you haven't got it, get it NOW!

    Use the tool, tool part 4

    If you've written some unit tests, the next thing to find out is how much of your code is covered, since you want to get as close to 100% as possible. This is where AQTime comes in. This profiler does all kinds of profiling but the coverage profiler is what you'll want to use here. AQTime may cost quite a bit of cash but it's worth every penny. Another use of AQTime is to track down performance problems. If I have a performance issue in some code, the first thing I do is turn to AQTime. Some people will think about what is causing their performance problems, but frankly what's the point? The theories they come up with are invariably wrong, because more often than not, the actual problem is caused by some poorly implemented algorithm, that manual analysis completely missed. Performance analysis should always be undertaken with the help of a profiler, since not only will it tell you the cause of the problem, but will also tell you exactly how much time you'll save by fixing it.

    Use the tool, tool part 3

    According to 'Working effectively with legacy code', any code without unit tests can be considered legacy code. That means pretty much every piece of software I've ever worked on is legacy code. Before .NET, writing unit tests was hard. In my Delphi days I tried to use DUnit but the language didn't lend itself to writing a tool that was simple to use. In .NET, attributes and reflection make it much easier. So we have NUnit, which has been the tipping point for me writing unit tests. As well as testing functionality, unit testing also helps validate the design of a system. If it's hard to write tests for your classes, chances are the design isn't too great. It suggests too much coupling and cohesion between the classes. Unit tests are always mentioned in the context of agile development, but there is no reason why they can't be used without adopting the whole philosophy. I have my doubts about some of the agile approach but I still believe unit tests are worthwhile. In the short term, they certainly add time to the development process, but I believe in the long run they save time and improve code quality. Of course management are often more interested in the short term (understandably since in the short term bills have to be paid), so unit tests may be a hard sell.

    Use the tool, tool part 2

    OK, before I get onto .NET tools, a bit of a diversion first into the realm of web based tools and HTTP. Fiddler is a great tool to see the traffic between IE and any web servers it's talking to. I've used it to track down performance problems and to see what cookies applications are using so I can hack them (meaning interact with them in a non-supported manner rather than steal credit card details...) If you're interested in HTTP calls that are made through some other app than IE, then TcpTrace is the tool for you. It's a little bit harder to set up than Fiddler (but not exactly difficult) and the UI isn't quite as polished but it gets the job done. It also supports any protocol, not just HTTP.

    Use the tool, tool part 1

    OK, the title is pinched from an article by Malcolm Groves, but I like it. After a week of having to work on an XLA written in the worst development language of all time, VBA, I suddenly realised the importance of using the right tools. You can be the best programmer in the world, but if you're using crap tools, your solution will still be crap. So here is the first in an occasional series of articles highlighting what I reckon are the best development tools. I spend most of my time doing .NET development, so I'm going to concentrate on that side of things. The first and probably most important tool is your IDE. And the clear choice is VS.NET 2003. OK, it falls over occasionally but I've very rarely lost any work. The choice is also easy just by a process of elimination. VS.NET 2002 was essentially a 1.0 product, so best avoided. VS.NET 2005 is a beta, so best avoided. And is just me, or is it one of the most butt ugly pieces of software ever? Delphi 2005 is, by all accounts, flaky as hell. Note, I still think Delphi is the best development language for Win32 client-side development, but for .NET forget it. SharpDevelop has one thing going for it, it's free, but other than that, it's pretty poor. So, almost by default VS.NET 2003 wins. Next time, more .NET tools

    Wednesday, August 02, 2006

    BPM software comparison

    Over the coming days/weeks/months (depending on when I get bored) I'm going to take a look at some Business Process Management (BPM) software and see if it's any good. What is BPM software? Good question. I'm in no position to give a definitive answer to that and I'm sure a BPM expert would give a different answer but to me it's all about automating all the boring repetitive crap associated with any business so workers can get on with more interesting stuff. Or alternatively workers discover they aren't needed anymore and get shown the door... The BPM market is growing and there are heaps of vendors out there producing software so I'm only going to look at products that meet one criteria, they have to provide a downloadable demo version of their software I can play with. If a company doesn't have the confidence to provide a demo then I am deeply skeptical of their software. So the vendors I'll be looking at will be (in no particular order) Savvion, Fuego, Metastorm, Tibco, Fujitsu and Microsoft. I may cover some more if I find they have demo versions I can download. Keep reading!

    Monday, July 31, 2006

    House price crash? I hope so

    When we bought our first flat in 1998, it cost us £99,950. At the time I thought it was a huge amount of money and I thought house prices couldn't rise any more. How wrong I was. Two years later we sold it for £175,000 and bought our current house for £220,000. Again I thought house prices couldn't rise any further and again I was way off the mark. In both cases I wasn't particularly concerned with house prices, since I never thought of buying a house as an investment but rather somewhere to live. Buying was (and still is) cheaper than renting for us since we were lucky enough to buy at a good time. Now our house is worth over £300,000 and by all accounts still rising, although the price rises have certainly slowed down. If we were starting over and looking to buy a place now we couldn't afford to, certainly not where we bought our first flat. I do wonder who can afford to buy somewhere now. But rising prices don't help us either. If we ever did want to move house, chances are anywhere we bought would be over the magic £250,000 mark, meaning our fees would be about £10,000. I can think of lots of things I could do with £10,000 and handing it over to the government doesn't seem the most appealing option. The guys at House Price Crash have been predicting a crash for some time, but they are still waiting for it to happen. The sooner the better as far as I'm concerned.

    Friday, July 28, 2006

    Windows Live Local vs Google Maps part 2

    So I tried to switch to Live Local but my first problem with it is a bit of a showstopper. The map doesn't show tube or train stations, so for getting round London it's completely useless. Back to Google Maps... Windows Live Local 1 - Google Maps 1

    Wednesday, July 26, 2006

    Windows Live Local vs Google Maps

    It all started with a trip to the wilds of Lincolnshire. We'd been there before but I didn't know the way too well, so thinking Google has the answer to everything I thought I'd use Google Maps to give us directions. Turns out the directions it gave us weren't too hot, causing much screaming and shouting between me and my other half who was trying to decipher the instructions. Admittedly where we were didn't help, all the roads and countryside looked the same. In the end we had to call the people we were visiting and ask for their help. Somehow they worked out where we were and guided us in. So for my next little trip I thought I'd give Windows Live Local a try. I was dropping my brother off at Heathrow airport so searched for directions for that. It's been a while since I've used the MS mapping stuff and it has certainly improved, in fact I think it may well have moved ahead of Google Maps. Google may have been first with the whole draggable map thing but they don't seem to have done a great deal since. But back to Heathrow, Windows Live gave sensible driving instructions and printing was completely customisable. Google Maps on the other hand suggested a completely insane route, via the M4. For the reverse trip it suggested a completely different insane route via the M25 and M3. Looks like Google thinks motorways are super fast which in the case of London certainly isn't the case. Final score, Windows Live Local 1 - Google Maps 0

    Cunts are still running the world

    Jarvis Cocker is back with a new ditty that won't be getting much airplay I guess. Not a great song but I can't help agreeing with the sentiment.

    Tuesday, July 18, 2006

    An unobjective review of Metastorm BPM 7

    First the disclaimer, I used to work for Metastorm, I use Metastorm e-Work/BPM most days for my job and I'm a techy so may not be interested in the same things as a business user of the software. Finally I haven't got my hands on the software yet, so can't comment on stability etc. And because of all that, this review will be completely unobjective and uninformed. First up, and possibly the least important new change, the name. To my mind, e-Work was a good name, if only because my boss's company ranks highly on the search term 'Metastorm e-Work'. BPM on the other hand doesn't set the software apart from every other BPM product out there. It's like Microsoft calling their word processor software 'Word', what they did? OK, perhaps I'm wrong... Having had a quick look at the webinar, there are quite a few new features. Metastorm seem to be making a lot of fuss about the SharePoint integration, I'm not hugely interested in this but if you're a SharePoint shop already it looks pretty sweet and much improved over the previous ActiveX implementation, perhaps not in features but certainly in acceptability in the corporate world. The Designer gets a makeover, going down the Visual Studio route with dockable windows, which should be pretty useful in terms of screen real estate. There are new icons, but they look pretty ugly to my eyes. There are a few new features (including the ability to specify roles in a library which made me laugh since this used to be possible until it was pulled out of the product for some reason). You can now find which procedures use which libraries in the database, which is most welcome. Internationalization has improved but is not complete. It also hasn't been added to the Outlook client which is a shame and perhaps signifies the Outlook client may be coming towards the end of its life. There is a new Integration Manager, although I'm unclear what this is for, integrating with the bought out CommerceQuest stuff I guess. Overall I'm pleased to see there has been a reasonable amount of time spent on the core product, rather than features required to be buzzword compliant (anybody using that rules engine integration?). My personal bugbear with the product is the e-Work scripting language that just isn't powerful enough as a scripting language. Unfortunately the integration with other scripting languages still needs improving and it looks like these two issues haven't been addressed at all.

    Friday, July 14, 2006

    MMC RIP?

    I never quite understood the point of Microsoft Management Console. It is a framework for building administration tools that allows end users to create their own admin environments by adding together as many 'snap-ins' as they like. But the cost of this is that any snap-ins have to fit into the MMC framework, which is fairly inflexible and forces an Explorer style interface on every snap-in. And who actually uses the customisation facilities provided? I certainly don't and have never seen a machine where the admin tools have been customised. So I was intrigued to see that the main admin tools in SQL Server 2005 are no longer MMC-based, they are just standard Windows applications (written in .NET methinks). So although Microsoft continue developing MMC (version 3 is coming out soon with support for .NET based snap-ins) it seems to me that the end may be nigh for MMC. As an aside, I helped develop an MMC snap-in for some software I worked on. Although they are generally pretty tricky to develop, Colin Wilson has written a great Delphi component set to help with the job if you really must develop one.

    Friday, July 07, 2006

    How to choose colours for a website

    With my grade E in GCSE Art, my art skills have never been up to much. So my website colour choices have always been pretty ugly. I was therefore very pleased to find Colour Blender, which makes the choices for you.

    Wednesday, July 05, 2006

    Ajax.NET Professional

    As always I'm late to the party, but I've finally got into some AJAX development. Since the project I'm working on is an ASP.NET 1.1 website, Atlas is no use to me, so I was pleased to find the free Ajax.NET toolkit. It makes development of AJAX based websites really simple. Add a line to web.config, add an attribute to a server-side method and then call it from client-side Javascript, it's that easy. The lovely thing about it is the way it copes with classes as well, my server-side method can return a class that can then be used in my client-side code. It may not actually be using magic but it sure feels like it.

    Sunday, July 02, 2006

    England suffer completely predictable World cup exit

    It came as no great surprise to see England getting knocked out of the World Cup yesterday. As ever, the first time they had to play a decent team, they failed to progress. But what made this worse than previous efforts was that we appeared to have a squad capable of making a real challenge. Unfortunately our manager was clueless and decided to only bring 3 strikers (OK 4 if you count Walcott who Sven was clearly never going to select), 2 of whom were not fully fit. That meant when Owen was injured we were forced to play a formation that clearly didn't work. If we'd been able to play a more attacking formation, we might have got a goal that we could have protected when we went down to ten men. But with two strikers, Rooney would probably not have been so frustrated in the first place and might have been on the pitch for the whole match.