harriyott.com

30 May 2006

Jack of all trades, master of none

I've found myself becoming increasingly envious of developers who become experts at something or other; the .NET CLR, MSBuild, CSS, ADO.NET, XML, web services, open APIs, Vista, or anything really. The people who have deep knowledge of a subject get to speak at conferences, write books, have really popular blogs, and even influence the future development of their field. They get asked the burning questions, and they are "known". If I needed an expert in CSS, I'd go straight for Andy Budd. MSBuild, Barry Dorrans. Internationalisation, Guy Smith-Ferrier. MS Paint, Leon Bambrick. And so on. And I'd expect to pay them handsomely.

As for me, well, I know a little about lots of things. I've not spoken at a conference, written a book, and I don't have a really popular blog*, and the only thing I've influenced was a typo in "Naked Conversations" (which I am ridiculously proud of). I spent years working for a consultancy, and every project used at least one technology that was new to me. I even had to do ColdFusion! I would just get the hang of something, and then I'd be on a different project. A couple of months after finishing a product, I'd find out about a feature of the tool I was using that would have saved me loads of time, made the code simpler, and been more satisfying to write. If only I'd known.

And now, I've been working for a product company, and I'm working on one single product in the company, with a small team. The product is written in .NET 2.0, so you think I'd be quite the expert by now, eh? Not so.

The first few months were spent researching all the new features of ASP.NET 2.0, such as themes, master pages, menu controls etc., and writing a GUI framework for the web application. That done, I spent some time importing XML files into the SQL database using XPath and T-SQL stored procedures. I set up a build machine using MSBuild. I improved our database maintenance tool (VB6) to run with MSBuild. I used C# for the general coding bits (I'd done around 3 months C# at the previous company). I set up a development team wiki. I've recently been using WinForms, threading, and creating installers. I've stood up and demonstrated the pre-alpha versions to our most important customers. In the next 6 months, there'll be Team System, Crystal Reports and the-proper-way-to-version-assemblies-and-manage-a-product-release.

I don't feel like an expert in any of these things. I've learnt just about enough to code the next feature. I'd like to spend a bit more time looking into threading in detail, but I've got to get the code to the testers. Then I'll have to start the next thing. I would read up on it in my spare time, but I'm already reading a books about CSS, ADO.NET (asynchronous connections are cool) and how the game of monopoly is a good metaphor for being an entrepreneur.

I knew this would start sounding like a fat whinge, and I've described it this way as there are many other developers in my position, and they may well grumble in a similar fashion. I want to relate to you, my fellow jugglers. However, I'm actually quite grateful for my "up-bringing". It has taught me self-sufficiency, adaptability, and thinking outside of the boxing / unboxing. It has made me brave and adventurous, versatile and nimble, selective and well-read, sleek and hunky. OK, sorry, maybe not sleek and hunky.

I'm not scared of any technology that crops up. I love learning about new things. My blogroll is full of people writing about stuff that doesn't impact me at the moment, but I understand the basics, and can talk about it, and I know that when a new problem arises I'll have more options to choose from. At the moment, I can't see a need for OPML, microformats, Ruby on Rails or Monad (sorry, what's it called now?), but when I do, I'll be ready. In the past, I've read about MSBuild, wikis, NUnit and CodeSmith on blogs, tried them out, and now use them routinely.

This well-roundedness makes me useful as an employee. My boss doesn't need an expert in the CLR, or the finer points of unicode. He needs someone who'll know what to do next, or know how to find out. So if you're like me, flitting from one technology to another, skipping through features and googling the error messages, remember that you are not inadequate, you're a developer.


* I have just proud of 50 subscribers, which seems amazingly high to me. I'm sure my blog is victim of "mark all as read" by quite a few of these subscribers.

[Tags: ]

26 May 2006

Using BeginInvoke to update the GUI safely between threads

An issue I've had a couple of times recently is updating (for example) a text box on a WinForms GUI. I'm coding away quite happily, and just stick in a

textBoxWeather.Text = "rainy";


or some such thing. This is fine, unless it's run from an event handler. This may be run from a different thread, which makes it unsafe to change something on the GUI. To get round this, the line of code should be put into a method, and be called using BeginInvoke:

delegate void SetWeatherCallback(String weather);


private void SetWeather(String weather)

{

    if (this.InvokeRequired)

    {

        SetWeatherCallback cb = new SetWeatherCallback(SetWeather);

        this.Invoke(cb, new object[] { "rainy"});

    }

    else

    {

        textBoxWeather.Text = weather;

    }

}


When calling this from a different thread, this.InvokeRequired is true, meaning that the thread can't access the GUI directly, so it calls BeginInvoke to call the same method (i.e itself) safely. This time, this.InvokeRequired is false, so the text box is changed directly.

I've needed to do this three or four times recently, and each time I couln't quite remember exactly what it was that I had to do, so I had to look it up. Yesterday I wrote a CodeSmith template to do this, which I've used twice today already. If you'd like a copy of the template, let me know.

[Tags: ]

23 May 2006

Debugging return values in Visual Studio

Let us suppose that we're debugging an application in Visual Studio .NET 2005. Let us also suppose that we have a method similar to the following:

// Let us also suppose that this is good code.
public int GetFalseStapleWotsit()
{
return staple.GetWotsit(false);
}

Let us suppose that we had a breakpoint on the closing curly brace, and that we had reached said breakpoint during normal debugging. Let us assume also that we have no code or .pdb for the assembly containing the staple object's class definition, and thus we cannot step into it.

How would we know what value staple.GetWotsit(false) had returned? There are no variables to show up in the autos, locals or watch windows, and there is nothing to hover over in the code. The only solution I have come up with so far is to put staple.GetWotsit(false) into the immediate window (Ctrl+D+I) and press enter. This calls the function again, and puts the returned value on the next line. Surely this can't be the best way. I'll just wait for a big-brain to leave me a comment to tell me exactly where I'm going wrong.

[Tags: ]

Free Intellisense for Query Analyzer

This is so cool. I've just downloaded a free licence for SQL Prompt, a splendid tool for SQL Server. It adds Intellisense to Query Analyzer, Enterprise Manager and a few other things.



It's only free until September 1st so, ahem, you'd better hurry.

From Scott Guthrie.

[Tags: ]

21 May 2006

Cartoon

I can draw stuff on my tablet PC now.

I've got a tablet PC

I want to be like Hugh Macleod. Never mind, eh?

First post from the tablet PC

This is so exciting. I'm hand-writing a blog post! I've never done that before. My friend Mark came round and fixed wireless networking. There were three problems. Firstly, Google Desktop Search had knackered DHCP. Secondly, there were two DHCP servers on the network, and thirdly, I hadn't realised that password and passkey were two different things!

It's actually a bit slower writing than typing. It's ok except when it doesn't understand a particular letter, and then navigating back through the text is a bit fiddly. Anyway, it's going to be great fun using this thing, especially with the voice recognition.

20 May 2006

My tablet PC has arrived

I'm so excited. I love it. I've been using Journal to see if it would actually understand my writing, and it does (which is more than my wife can do). Two problems so far: whilst I can connect to my wifi hub (which is connected to the broadband router), I can't get the tablet online. The other problem is that the rest of the family are wanting to use it. Here's a picture of Toby (my 4 year old son) practising writing his name on it.

Toby learning to write on a tablet PC

How cool is that? Being 4 years old and learning to write on a tablet PC? Back in my day...

[Tags: ]

17 May 2006

ContextSwitchDeadlock was detected when debugging in Visual Studio 2005

I've been having issues with a "ContextSwitchDeadlock was detected" error message popping up when debugging. The message text is a baffling

The CLR has been unable to transition from COM context 0x197060 to COM context 0x196ef0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.

I've read a few things about a config file, but I couldn't get this to work reliably. Instead, you can switch the MDA off by going to:

Debug -> Exceptions -> Managed Debug Assistants

and unchecking the ContextSwitchDeadlock item. Thanks to Scott Munro.

[Tags: ]

New tablet PC: HP TC4200

In a moment of recklessness and frivolity, I just bought a tablet PC on eBay. I needed to get a second computer, as Julia and I have progressed from hogging the TV remote to hogging the desktop computer. ("I need to email this tonight", "But I'm in the middle of something" etc.)

HP TC4200

Technically, I don't actually need a tablet PC. I could have bought any old laptop. But I've wanted one for a while, as a kind of "luxury item". If push comes to shove, I've got a load of excuses, reasons and justifications for buying it (e.g. I don't have an XBox, PSP etc, and my only TV is a 14" portable, so I can have a different toy etc.).

I was going to wait and post this when it arrives, but I'm so excited I just had to tell someone.

[Tags: ]

15 May 2006

New spam game

I found a rare specimen in my GMail inbox just now - a spam email. It "cleverly" contained a passage from a novel. I've seen one other example of novel spam, but this time I thought I could identify where it came from. I googled the character's name, Sergey Ivanovitch, which confirmed I was correct - it was from Tolstoy's "Anna Karenina".

I mention this not because I'm impressed with the novel approach taken by the spammer (pun fully intended), nor because it is now noteworthy that Google didn't pick it up as spam, but merely to alert you to the fact that, despite evidence to the contrary, I am slightly cultured.

Anyway, this could be quite an interesting game to play with your friends. If you receive any novel spam, email your friends one at a time until a) somebody identifies it, or b) you lose all your friends.

[Tags: ]

14 May 2006

I feel really thick tonight

I've inherited a client's PHP / MySQL / PHP Nuke website, and I've not used these technologies before (I'm a .NET / SQL Server guy). I successfully installed PHP and MySQL a couple of weeks ago (older versions, it seems), and downloaded the source from the web server. I managed a database backup from the server too (there was an option on the PHP nuke admin page).

Tonight I've been trying to actually get the thing running, having no idea where to start. I don't know the simplest things about MySQL, like where do I type the SQL? What is the equivalent of Enterprise Manager? I've answered the first, and hopefully not answered the second. Usually with software, I can download it, fire it up, and make a pretty good guess of how it works. This time I've had to read the manual quite a lot, which I guess is a good thing.

Anyway, I've just restored the backup onto my installation, and I've got a different PHP error, so I've clearly been successful. Now I've just got to fix this error, and see what happens next. When I actually get this all running, then I can start making it look pretty.

[Tags: ]

11 May 2006

My love / hate relationship with customer demos

I love customer demos. I love seeing the customer realise that what I've written is going to make his life easier, or save him some time, or give him more control, or just be more useful. I love getting suggestions for making things better, and hearing about how the customer's business works, and being able to visualise a person actually using my GUI whilst I'm writing it.

I hate customer demos. I hate how long it takes to set up a machine to work correctly. I hate having to stop developing the product during that time, knowing that there's a milestone deadline brewing. I hate having to spend time quickly hacking together a feature just to demo, with made up test data, that doesn't do anything yet, but still must be shown.

[Tags: ]

9 May 2006

Fifth Sussex geek dinner

I chose a particularly poor night for this geek dinner, as many previous diners were unavailable. We had three new geeks join us for the first time tonight, two of which I hadn't met. I met Tom Morris at the London geek dinner last week and invited him along, and Matthew Taylor and Clive Walker had emailed me out of the blue.

We went to Zizzi in Haywards Heath, which although the food was good, it was easy to get to, and the surroundings were very nice, it wasn't as suitable for a geek dinner as the Highlands was. The music was just loud enough to make hearing people tricky at times. The London geek dinners now have a buffet, which makes talking to people a lot easier (although the ham rolls don't even begin to compare to my delicious crayfish salad). Because of where I sat, I didn't get to talk to Sven, Matt or Clive as much as I would have liked. [Attendees: please leave a comment on whether you would prefer a buffet in future.]

Topics of conversation: some of our Mums are getting quite computer literate, using del.icio.us, gmail, Thunderbird and Firefox (very very frightening me. Galileo..) etc; Blogging style is affected by blogging tool; wooden aeroplanes; VB.NET training course; new jobs; taking the leap into contracting; how hard it is changing blog platforms.

[Tags: ]

List of developer tools

One of my colleagues has remarked on my array of handy free tools that help with development, and life in general. So, here's what I use, and why:
  • Reflector. For viewing the source code of assemblies, and checking the version of referenced assemblies.
  • Less MSIérables. View the contents of an installer or merge module. I've changed it so the files are in alphabetic order, and highlighted duplicate files (a common problem for me).
  • Notepad2. Like notepad, only with syntax colouring, word wrap and other good stuff.
  • World's 2nd simplest code generator. For smaller tasks where CodeSmith would be too much.
  • AutoCopier. Something I wrote to copy assemblies to other directories as soon as they're built. I might release this to the world somewhen.
  • Process Explorer. An alternative to task manager, which (amongst many other things) shows which DLLs are loaded by an executable.
  • SlickRun. A quick way of launching programs, files and websites from one small place.
  • BGInfo. Display system settings on desktop wallpaper.
  • Cropper. For creating screenshots without using a graphics program.
Many of these I found through Scott Hanselman's list, which is way bigger than mine.

[Tags: ]

8 May 2006

Sussex geek dinner

The next Sussex geek dinner is tomorrow night in Haywards Heath. Full details on the Sussex geek dinner site.

[Tags: ]

2 May 2006

London geek dinner with Marc Canter

Marc was on fine form, talking about his "People Aggregator", which will be out in a couple of months. From what I gathered, this will take all your content from your social networking accounts (Live Journal, Yahoo!, Bebo etc.) and aggregate them. If, for example, you have three different friends lists, these can be aggregated into one. All this is done through the public APIs, so if a site doesn't have one, then it can't be aggregated. It sounds good, and I'll probably try it when it goes live.

I met some new people, including Lars Plougmann, who met my boss recently, and Tom Morris, who I travelled back with on the train. He showed me Dave Winer's OPML editor, which looks really cool. Having said recently that I didn't quite get the point of OPML reading lists, seeing Tom's lists made it clearer - it's about subjects, not blogrolls. Due to Dave Winer falling out with someone, Tom gets to do a presentation about it at a conference in the states (can't remember which one).

Walid has found a developer for his review / maps site, which he expects to be out in a couple of weeks. Hopefully at the next geek dinner it will be live. Had a chat with Nick Swan about microformats, in which we concluded that they are easy to write, hard to read.

[Tags: ]