Friday, May 30, 2008

Help Microsoft Donate

I just noticed a post by Nick Hodge about Microsoft Donating to The Smith Family (a charity). The problem is, they need your help. Pop over to this site and watch the video. For every person that views the video, Microsoft will donate $1.

(Just a note, I'm sure this is a promotion to help spread the Silverlight love, but I think it's a very worthwhile cause non the less.)

Friday, May 16, 2008

An interesting use for using

A college of mine came to see me the other day with a question about some code he had stumbled across. He wasn't exactly sure what it did, or more importantly, if it's something that he should be doing in his code. The code in question was a using block. Now, I'm right up there, telling people that they should have using blocks in their code for any object that implements IDisposable.. The problem was, the object in the using block didn't..

Now, I found this to be very interesting.. myObject was an instance of an object that clearly didn't implement IDisposable. Performing a cast like this would actually result in a null reference. The compiler was happy, the cast was invalid, and it ran without any problems at all.

I took a peek at the IL generated, and was pleasantly surprised to see that there is a check for nulls before the call to dispose.

I'm not sure if there is any benefit from doing this, and I'm sure I wont be recommending this to anybody, I just thought I'd mention it as an interesting tidbit.


Vista and Office 2007

I just wanted to go on the record.. I really really really like Vista and Office 2007...

See, when both Vista and Office 2007 came out, I upgraded.. I've done this for every version of Office/Windows (except for Win ME...) since Windows 95. So far, I can't say I've ever had any major problems with an upgrade.

Back to Vista and Office.. The dev machine I had at home was a little under powered. I also play games, and the machine was struggling under the load. So, I did the right thing and built a new computer. It wasn't all singing, all dancing.. It was just a nice system. I met all the recommended requirements etc, 2 gig of ram, a decent video card etc. The end result was a system that ran fine, and for a smidge over $1000.. (This was just the computer, not the monitor etc..)

To date, I still haven't disabled UAC.. I've deliberately left it on.

Anyway, the point of my post is that I have not encountered any problems with this system to date, no stability problems, no performance problems, nothing.. Well, not completely try, I have had 1 driver problem, but that was with a Netgear NAS (very cheap.. And sucked under XP anyway..) that didn't have drivers for over a year after the release of vista.. This is clearly a problem with the vendor (or the people that made the re-badged toaster looking NAS box they sold)..

As for Office, wow.. Sure it was a shock at the start. The ribbon is a big change, but once I spent time to actually use it, I fell in love.. Back at work, I'm still running on XP and Office 2003, and I have to admit, I find now that I miss the ribbon....

I'm glad the upgrade process for both Vista and Officer is underway at work ;)

Thursday, May 08, 2008

WCF and Inheritance

Anybody who has had the pleasure of working with WFC, or in fact any messaging based programing will understand the issues related to messaging and inheritance. For those that don't, here is a quick rundown.

Take this situation:
I have a person class with:
  • First Name
  • Last Name
  • Age

When serialised, I get something like this:

FirstName: Eddie
LastName: de Bear
Age: 30

Now this so far does not cause any problems. It's designed to work like this. When a service receives this message, it knows exactly what it is dealing with.. A Person.. That's what the contract defines, that's what it gets and deals with.

Now, Imagine I now have a new class Employee which inherits from Person and adds a single attribute, EmployeeId.

Now, when this gets serialised, what do we see:

FirstName: Eddie
LastName: de Bear
Age: 30
EmployeeId: XXX-123-XXX

(This assumes that the new Employee class still has the same contract name etc..)
Now, if this was passed to a Service that expects a person, the service has a little heart attack. It has no idea what to do with the new attribute EmployeeId.. It's not part of the person class..

There are a number of solutions to this, such as Method Overloading. But one of the solutions I find the most interesting is the mechanism WCF uses for Contract Versioning. IExtensibleObject.

In the example above, you could easily implement IExtensibleObject on the original person class. IExtensibleObject basically provides a property bag for dumping extra information that is encountered at deserialisation time. This allows the service to continue to treat the Employee object as a person, without loosing the additional information added by the employee class.

A great article on the use of the IExtensibleObject interface can be found Here

Improving output

So, a while ago I found myself getting a little behind with my work. I found myself constantly caught up in meetings, spending a large amount of time communicating with team members and stakeholders. In fact, I found that more of my time was taken up with this that I could really afford, something had to be done.

So far, I have actually had little success in reducing the number of meetings that I need to attend. This is something that I'm sure keen to work on, but find that getting these meeting taken offline (email, IM etc) still has a great deal of resistence in the workplace, people like face to face contact.

What has changed though, is my productivity.. No, I still refuse to use code generators.. But I have found myself adding Code Snippets to Visual Studio at an absolutely astonishing rate. I find that code snippets provide me with the best of both worlds, I don't need to continually waste time writing the same templated code repeatedly, and the overhead of creating them in negligent.

So, what sort of things do I use the Snippets for.. The answer is easy.. Any repetitive work.
  • Properties with Change Notification
  • Data Access
  • Service Contracts
  • Data Contracts
  • Exception Handling
  • Anything else I type repeatedly

Basically, I find that by removing the tedium of these repeated tasks, I can spend more time focusing on the actual business specific problems.

Productivity ++

Friday, May 02, 2008

It helps to read the manual..

I've had my i-Mate Jasjam for a little over a year now, and for the most part it's been very reliable. As of late, I've been having a little bit of battery problems. In particular, it's because most applications continue to run even after clicking on the little X in the top right hand corner.

Over the last year, I've slowly added more and more applications, and tend to spend more time surfing the web (or just have programs like tinytwitter running).

Anyway, today I stumbled across a little feature that I'm sure was not on the original WM5 rom that was loaded when I got my phone, but was added by I-Mate in the WM6 rom. Basically, it actually closes the application when you hold the X button for a few seconds. This avoids constant trips to the task manager and clicking the "Stop All" button..