Thursday, May 31, 2007

A grey water experiment


We are constantly told that investing in a water butt to water our gardens is a good thing, it saves water and hence the planet. What is never mentioned is the fact that when you need it most, your water butt is probably not going to be much use to you. When it hasn't rained for several weeks and the inevitable hose-pipe ban is in place, you water-butt won't have a drop of water in it. Because of this, my water butt isn't getting filled up with rain water. Although the general consensus seems to be that using grey water for watering your garden may not be a good idea, as ever I decided to ignore any advice given to me and hooked our water butt up to the outlet from our bathroom. I'm not sure all houses are configured like ours, but the used water from our sink and bath goes out through a couple of pipes into a drainpipe so using this for the water butt was very simple.


And it seems to work fine. The water can smell a bit, but it doesn't seem to kill our plants and we can water the garden without feeling any guilt. One thing, remember not to wee in the shower... Although I'm sure you'd never do such a thing.

Wednesday, May 23, 2007

More on JScript exceptions

I don't know much about JScript, so when I need to find out anything I head off to Google. So that's what I did when I wanted to know about throwing exceptions. Almost every example I've seen shows something like - 

throw "something went wrong";

Initially I thought this would be wrapped up as an exception by the JScript runtime, but it turns out it is actually a string that gets thrown. Which may be fine in some cases. The problem comes when you want to catch exceptions. If you want to catch all exceptions thrown in a bit of code (yeh I know, bad idea, but this is JScript not software engineering...) then things will get complicated. The runtime will throw exceptions but your own code is throwing strings, so you have to deal with them differently. Turns out the solution is pretty straighforward -

throw new Error("something went wrong");

Now everything is an exception and life is good.

As a side note, I've not considered throwing anything other than an exception before. C# doesn't allow it, although I guess IL probably does since it needs to support JScript.NET. Delphi partially allows it, you can throw any object you like but not strings since they aren't proper objects in the Delphi world. But it's not clear to me why you'd ever want/need to do it...

The new Google Analytics

So there's a new version of Google Analytics available which is lovely and shiny and new. But they seem to have removed the ability to show data by month or hour. Monthly data is useful to get an overview of how traffic is increasing/decreasing over time, since daily data is too volatile. Hourly data is great to see what's happening on your site today.

Tuesday, May 15, 2007

Why I'm not using UAC

Lots of people keep saying I should switch User Access Control on. So I thought I'd give it a try since I wanted to see how painful it was or if it was actually not so painful after all. And of course I'd like my software to run with UAC enabled without causing any issues.

But here's the problem. Vista is already screwed up on my machine, what with no sound, a SonicWall VPN client that screws up TCP/IP and complete machine freezes every couple of days. And UAC makes it even worse! Internet Explorer has some serious problems when UAC is enabled. It won't print, links that open new windows don't work and the dropdown menu on the back button doesn't work. Explorer always opens folders in a new window, even though it is set up to reuse the same window. Lots of applications won't work at all unless I run them as administrator (Visual Studio being the obvious example) which rather defeats the point of UAC. And these are the problems I've found after using UAC for about two days so there are bound to be more.

And of course I've not even mentioned the annoying dialogs that appear fairly regularly to disrupt my workflow.

So in principle using UAC may be a good thing and dogfooding it constantly with my own code would be a nice thing to do, but in practice it is too painful and I'm putting it back in its box until SP1 comes out. 

Monday, May 14, 2007

How the web was won

In one of my previous jobs I was responsible for helping to develop a native Windows client. At the same time, a web client was developed by another team. Although the native client had some advantages (it was much quicker and generally more reliable*), the web client was much more successful. I suspect this was mostly down to the deployment issues you have with a native Windows client. Even now in a world of ClickOnce deployment, web clients are still preferred by a lot of customers.

But one thing that has become apparent to me since doing more integration work is that web clients also have one other major advantage over native clients. Whether you intend to or not, when you develop a web client you get a plugin architecture for free. Doing the same thing in a native client takes a lot of thought and development time, but anybody can hack around with a web client to make it look like they want or do what they want, via CSS, Javascript or even server-side hacks with some systems. Yeh, these hacks may well break between releases, but it still makes web stuff very attractive to integrators. To do the same thing in a native client would likely involve going back to the vendor to ask for a change in functionality or an extensibility point where code can be plugged in, which might take months, rather than an afternoon of fiddling around. And that I reckon is the killer reason why the web has won.

* This was no reflection of the development team working on the web client. It's just that, all other things being equal, writing a native Windows client is much simpler than writing a web client.

Tuesday, May 08, 2007

Virtual Earth vs Google Maps part 3

Many moons ago I tried out Windows Live Local (now called Virtual Earth I think) and decided it didn't meet my needs since it didn't show any London tube stations or train stations which made getting round London kind of difficult. I checked it out again today and it now has got tube and train stations. This is actually a step ahead of Google Maps that only show tube stations. However it seems to be a bit buggy currently since sometimes stations appear at one zoom level, disappear when you zoom in, then re-appear again after more zooming, which I presume is not by design. Check out Herne Hill.

So finally these Web 2.0 sites have almost caught up with Streetmap, which I don't think has been updated in about 5 years. Kind of shows up the 'we move in a fast moving industry' mantra as a complete lie.  

Friday, May 04, 2007

Even more on tick marks in HTML

It's always the seemingly simplest probems that have the most long-winded solutions. So my last post was wrong, although that solution worked in some HTML docs, as soon as I switched to HTML 4.01 FireFox started showing extra crud, as you'll notice if you're viewing this in FireFox. So here's a solution for tick marks in HTML 4.01, still using conditional comments, which works in IE6, IE7 and FireFox 2, probably...

<![if !IE]> &#10003;<![endif]>
<!--[if IE 7]> &#10003;<![endif]-->
<!--[if lt IE 7]> <input type="checkbox" disabled="disabled" checked="checked" /> <![endif]-->

And to complete the whole thing, here's an XSLT template to put a tick mark in your HTML output.

  <xsl:template name="outputTickMark">
<xsl:text disable-output-escaping="yes">
&lt;![if !IE]&gt; &#10003; &lt;![endif]&gt;
&lt;!--[if IE 7]&gt; &#10003; &lt;![endif]--&gt;
&lt;!--[if lt IE 7]&gt; &lt;input type="checkbox" disabled="disabled" checked="checked" /&gt; &lt;![endif]--&gt;
</xsl:text>
</xsl:template>

and here's a tick mark that might work this time.



By the way, I found this article on conditional comments particularly useful.

Update: The absolute final word on this subject is here

Wednesday, May 02, 2007

More on tick marks in HTML

My original post about displaying a tick mark in HTML is one of the more popular hits on this site. This fact and the increasing usage of IE7 and FireFox drove me to come up with a nicer solution than the one proposed there (using the lowest common denominator checkbox input field).

Internet Explorer supports something called conditional comments. Using these you can serve up different content to different browsers directly in your HTML, rather than doing funky server-side things. I have to use this approach since I'm generating a static HTML file. So here is the markup -

<!--[if IE 7]><!--> 
&#10003;
<!--<![endif]-->
<!--[if lt IE 7]>
<input type="checkbox" disabled checked>
<!--<![endif]-->

The if IE 7 comment will be rendered by IE7 and any other browser. The if lt IE 7 comment should only be rendered by IE6 and below. I've tested it in IE6, IE7 and FireFox 2, which covers enough bases for my needs. And here is the output, which hopefully should show some kind of tick mark.


Update - there's a more up to date and correct version of this available here

JScript try catch syntax

I alway forget the syntax for JScript exception handling and searching on the web always seems to bring up the wrong thing, so here is an example as my own personal reminder.

    try
    {
        // do stuff
        return "blah";    
    }
    catch(e)
    {
        return e.message;
    }

Yeh, I know, I should be able to remember that... I blame it on the crap JScript editors, none of which provide the mental crutch of code completion.

Remember too, JScript requires the e, you can't use catch().

Sunday, April 29, 2007

SonicWall VPN Client for Vista beta

One of the problems I've had with Vista is the fact the SonicWall VPN Client doesn't work with it and SonicWall haven't released a new version for Vista. Well they've finally got their arse in gear and released a beta version of the VPN client.

Send an email with “subscribe” as the subject of the email to gvc40-join@listserv.sonicwall.com if you’re interested in participating in the beta program.

It kind of works for me, although after a while Vista complains that two PCs are connected to the network with the same IP address. Then everything falls apart. Restarting the VPN client and my wireless connection fixes the problem.

Addendum (28th October) - The SonicWall VPN client for Vista is now out of beta and it is all working fine for me now.

Phew, it's not just me

First off, Canary Wharf is one weird place. I haven't been there for a while but it's almost like it has a dress code, everybody is wearing a suit, or shirt and trousers at the very least. So when I rolled out of the station in my old jeans with a few days facial hair growth I thought I'd be picked up by the police as a terrorist suspect. Fortunately I didn't bump into any police men. I was fairly sure Credit Suisse wouldn't let me in either but perhaps they'd been warned that a group of geeks was visiting.

I was attending a London .NET User Group meeting for a talk about Windows Workflow. The first part of this talk was reasonably interesting, although it was clear the presenter has been reading the same book as me, so a lot of it wasn't new to me. But things got interesting when one of the guys who's been developing a WF application at Credit Suisse talked about their experiences. The things that came up were pretty much the same issues that I've come up against.

First, the versioning story just isn't there yet. Storing serialized objects in the database means upgrading workflows can be somewhat tricky, since after an upgrade the deserialization is unlikely to work. Which is why I think using serialization is generally a bad design decision, unless the life of the serialized objects will be very short (copying to the clipboard, sending an object across the wire etc). So they've been forced to write some code to get pertinent information from the live workflow, destroy the instance and recreate it using the new workflow version and re-assign the state data.

The second problem is actually caused by the same issue. You might think since the workflow is stored in a SQL Server database, you could just query it to find all the instances that have a particular property, but again the fact that the worklfows are opaque blobs means this isn't possible. They worked around this by extending the persistence service to store relevant data relationally whenever a workflow is persisted.

It's nice to know that most problems can be worked around. There is so much flexibility in the WF hosting and runtime that almost all of the default implementations can be re-implemented to do what you want. I just hope this doesn't lead to Microsoft not fixing what are clearly problems with the default implementations.

One final thing that was mentioned that I was coming round to thinking myself is that state machine workflows are actually the way to go for many kinds of problems. Most of the talk in books and the web seems to be about sequential workflows but I think state machines are actually a better way to go most of the time. Of course this may just be due to my background in Metastorm e-Work which uses something closer to a state machine than a sequential workflow.  

Friday, April 27, 2007

More Vista pain

I finally cracked. I'd had enough of the complete lack of support from Dell about my lack of sound on Vista. The guy said he'd get back to me, of course he never did. Emails to Dell got no response. Yeh I could kick off another support call but it would just involve several hours of them uninstalling and installing drivers and failing to get anywhere, which I've been doing pretty well myself for several months. To top it all off, Dell sent me an email asking me to fill in a questionaire about my customer service experience. When I clicked on the link, all I got was a message telling me my access had expired. They even sent me a reminder to fill in the survey a few days later, again access expired. Hey Dell, there may be a reason you're not getting much feedback on your customer service...

So I thought, stuff this I'll buy a new soundcard, £20 and all my pain will go away. It all started out really well, Vista recognised it, went away to find the drivers and everything installed correctly, or so it said. Then I tried to actually get some sound out of the PC, nothing, nada, zilch. I pressed the dreaded 'Test' button, 'Failed to play test tone'. Aaaagh! Cheers Vista, why couldn't you play the test tone? I almost long for the usual massive hex number, at least something to work from. The event log is empty.

So now I have no idea what the problem is caused by. Presumably it isn't a driver or hardware problem, so is my Vista install broken? I really don't want to reinstall the whole thing.

On another note, Vista has developed a nice habit of locking up completely, the mouse stops moving, the keyboard doesn't respond, CTRL-ALT-DEL does nothing, the only thing I can do is hit the reset button.

Five years, thousands of developers and what do we have? A prettier version of XP that for me is less stable and other than IIS 7 doesn't really offer much new.

Tuesday, April 24, 2007

Recruiters - how about reading my CV?

I'm not looking for a job currently but my CV must be out there somewhere on the internet from the last time I was looking for work. And it's pretty clear quite a few recruiters just do a keyword search and send out emails without actually ever reading my CV. So I've had emails about C++ positions, which I haven't touched for almost 10 years, PHP jobs, which I'm familar with but wouldn't consider a strong point, testing jobs and even jobs in the US.

Maybe the 'throw enough shit at the wall and some of it will stick' technique works but I suspect it's not highly effective. I tend to remember the recruiters who actually bother to ring me up and actually listen to what I have to say and if I ever need to contact a recruiter again I'll go to them first, since they appear to care about placing people in the right job. The others are simply helping to confirm the bad reputation that recruiters have.

Monday, April 23, 2007

The ZX Spectrum is 25 years old

And how old does that make me feel?* Get an emulator and download some great games at World of Spectrum, read more about the mad genius Clive Sinclair at Wikipedia.

* Short answer - very

Friday, April 20, 2007

How to solve virtually any technical problem

People ask me technical questions all the time. I have no idea why, I don't know any more than anyone, perhaps the fact I can find the answer to these problems leads people to think I actually know the answer. So I'm going to present to you the two steps to find the solution to almost any technical problem.

Google for it - The internet holds the answer to pretty much any question you can ask. The key to finding the answer is to know how to search. This is pretty much trial and error, if one search doesn't bring up the answer, try another phrase until you get something that looks related. If you're getting a specific error message, search for that.

Another point to make here is that if you can't find what you're looking for, consider whether what you're trying to do is a good thing to be doing. I remember trying to find information about hosting .NET WinForms controls in Internet Explorer and not having much luck at all. This was a big red warning light to me that perhaps even attempting to do this kind of work was a bad idea since it would appear very few other people were doing it.

Infinite monkeys - You know the saying, given an infinite number of monkeys with an infinite number of typewriters and infinite time, one of them will produce the works of Shakespeare. So it is with fixing technical problems. Try enough things and one of them will be the right answer. The key to this technique is only to make one change at once, otherwise one of your changes may fix the problem and your other change might break it again. Or you forget one of the changes you made and don't set it back to what it was before and you're in an even worse position.

So now I've given you the tools, you don't need to bother me anymore, OK? 

Tuesday, April 17, 2007

Buy less crap

The idea touted by Red that somehow we can help charities by buying more stuff is frankly preposterous. The idea put forward by Buy (Less) Crap is to not purchase more consumer tat and donate the money we would have spent to charity instead. Now that seems much more sensible. How many fecking iPods do we need anyway?

Monday, April 16, 2007

Doogal's guide to parenting

You can read every book by Gina Ford you want but from my vast experience (ahem) there are only two things you need to master when bringing up a child.

Bribery and blackmail. 

Friday, April 13, 2007

No really, total rewrites don't make sense

I just found this fairly old blog post about rewriting Delphi apps in C# which sits so well with how I think (and puts the point across far more eloquently than I could ever do) that I had to post the link.

The bottom line is if you have an old code base to maintain, rewriting it completely may seem like an attractive option, but there are other ways of getting to the same place without throwing away years of investment in that old code base.

Wednesday, April 11, 2007

Swimming to New York

I'm not the first person to point out the humorous suggestion from Google Maps when you ask for directions from the UK to the US (see step 36), but it got me thinking.

One of the shortcomings of Google Maps is that it has no knowledge of anything but driving so it won't advise me to jump on a plane if I want to get to the US. For that matter if I ask it how to get to London Waterloo from my house, it doesn't know anything about trains so again will tell me how to drive there. It doesn't know anything about congestion charging or parking charges either so doesn't realise only the super rich or super stupid would ever consider driving into central London.

Transport for London has the opposite problem because it completely ignores the driving option, which in some circumstances might make sense (try taking public transport from SW London to SE London without dying of old age on the way for instance).

A while ago I wanted to investigate transport options for getting to my dad's house in Spain. Here things get even more complicated. There are loads of different websites with information about planes, trains and ferries but I had to find them and then compare prices, times etc.

But none of this stuff is properly integrated. The data is mostly available so it just requires an uber geek to figure how to build a mashup site that takes data from all these different sites and pulls it together in one place. I need to be able to enter a start location, an end location and then be able to get results sorted on which is cheapest or fastest or most environmentally friendly and lets me buy all the required tickets. Presumably if somebody did make such a thing, they could probably finance it by getting commission on the bookings.

And another thought, my guess is one of the reasons people who may be concerned about the environment still take flights rather than taking the overland option is that it is so much easier to book a flight than to book the alternative train and ferry. Oh, and cheaper... Er, and quicker... But at least this site could remove one obstacle.

So, any takers?

Tuesday, April 10, 2007

Maintainable XSLT

Doing a search on Google for 'maintainable XSLT' doesn't throw up a great deal but it seems like something that is really needed. There seem to be lots of resources out there telling me how to code in XSLT, but I haven't found any telling me how to do it elegantly or testably (is that even a word?). I've been working on and off on a project that takes an XML file and spits out a HTML representation of it. When I started off I decided to go with XSLT, rather than generating the output in C# using an XmlWriter. I still think that was the right decision. Even though XSLT is pretty verbose, generating HTML any other way isn't too concise or pretty either.

It's not a big XSLT file by any means (about 1500 lines), but I'm already finding it hard to manage and the tool support just isn't there. Visual Studio 2005 is a step up from 2003, but there are still plenty of things missing. There doesn't seem to be a way to get an overview of an XSLT file by showing what templates are in it. This means some of the possible advantages of splitting it out into separate templates are lost. But even if I was to split it out into separate templates, the markup required to call a template means the XSLT file might actually get bigger due to the calls to the templates!

Another thing I'd like to see is the ability to go to the definition of a template from a call-template call, but that doesn't seem to be available. How about regions, like in C#? OK, I want all the features of the C# editor in XSLT, am I barking up the wrong tree? XSLT is fairly different to C# and I'm coming at this with the mindset of a C# programmer but are there different ways of handling this complexity? Where should I be looking for this information?