Monthly Archive for: ‘September, 2006’

How do other people view me?

0

I just had a horrible thought:

For months now I’ve been using the new MS fonts in my emails – the body text is in Calibri (the default for Outlook 2007), and I use of smattering of Consolas in my signature to space out phone numbers and other contact details neatly.  I think it looks pretty good, very modern, very clean.

BUT – what if the recipients don’t have these fonts installed on their system?  How does it degrade?  Will they see a sensible alternative, such as Arial or Verdana, or will it just render in *shudder* Times New Roman!?  People will think I have no taste!  That would be nearly as bad as those folk who insist on sending business emails in 16-point fuschia Comic Sans MS!

Experience?

0

I’ve always thought it a bit stupid the way that recruiters ask for a set number of years experience in a given skill.  As any coder worth their salt knows, doing menial codemonkey tasks every working day for a decade doesn’t put you in the same league as a guru who burns the midnight oil to become an expert in a given field.

So, I found this comment on the Daily WTF forum particularly accurate:

"When some people work at a place for ten years they get ten years of experience, other people work at a place for ten years and get one year of experience ten times."

So true.
 

Cashless Car Parking

1

In these days when practically all goods and services can be acquired with the right credit card, the few that still force me to carry cash are increasingly frustrating.  When they require exact change, and don’t accept banknotes, well, that’s just plain ludicrous.

Now that we have moved out of York city centre, trips back into town invariably require us to park the car, which invariably involves feeding a Pay & Display machine with anything up to £9.50.  But what are the chances of having that much change to hand, unless you’ve planned ahead of time?

So, I was intrigued to see that the city council have teamed up with Verrus to provide cashless Pay By Phone parking, and decided to give it a go on a recent trip to a city-centre restaurant.

The process works something like this:

  • You register your mobile phone, credit card and vehicle details with Verrus.
  • On arrival at a car park, you phone the number shown and are asked to enter your phone number, PIN, a four-digit location corresponding to the car park you’re in, and the number of hours for which you want to park.
  • Parking attendants carry mobile devices showing that your vehicle is legitimately parked
  • Your credit card is charged the appropriate sum.

Sounds good, yes?  But here are some of the drawbacks I encountered that will lead to me probably not using this service for a second time:

Firstly, the phone number you have to call is a national rate (0870) number, which costs about 12p per minute from the average mobile.  The call only took 72 seconds, but even so, that’s inflated my cost to park.

Secondly, for the privilege of paying in this manner, I was charged a surcharge of 20p.  No fair.

Thirdly, the system failed to figure out the parking cost correctly.  I arrived at 1651, wanting to park for two hours at a cost of four pounds.  The robot voice told me that “parking for two hours is equivalent to parking until 4am at a cost of six pounds” – huh? WTF?  In the end I chose to park for just an hour, ate quickly, and slightly overstayed my welcome.

Would it be so difficult to provide pay and display machines with a credit card slot?  Or machines that accept banknotes?

A Serializable KeyValuePair Class

9

Having accepted that Returning DataSets from WebServices is the Spawn of Satan and Represents All That Is Truly Evil in the World (or at least, not exactly best practice), I’ve been trying to make a conscious effort to instead use lightweight custom objects in my middle tier, to be exposed via web services for use by other applications.  I felt sure that some of the new Generic classes in the .NET 2.0 FCL would help me in my quest.  Specifically, as I often need to expose simple arrays of Key/Value Pair metadata, I planned to create an instance of the  System.Collections.ObjectModel.Collection class, containing a bunch of System.Collections.Generic.KeyValuePair objects. 

Well, this all seemed to go to plan, and worked just fine within my app.  But when I exposed the method as a web service, I discovered that neither the Key nor the Value properties were serialized – I was left to consume a lovely generic collection of objects with no members – not a whole lot of use.

A little Googling turned up this blog entry, which explains that the Key and Value properties on the KeyValuePair class are both read-only, and by design the XmlSerializer will not serialize properties that don’t have a set accessor!

Damned if that little matter was going to stop me, I whipped out my copy of Lutz Roeder’s reflector to reverse engineer the KeyValuePair class (to be honest, I could have guessed most of it), and added a private set accessor to both properties, thus persuading the XmlSerializer to, well, do some serializing :-)

Here’s the code for this new class:

using System;
using System.Runtime.InteropServices;
using System.Text;
namespace IanFNelson
{
/// <summary>
/// It's just like a System.Collections.Generic.KeyValuePair,
/// but the XmlSerializer will serialize the
/// Key and Value properties!
/// </summary>
[Serializable, StructLayout( LayoutKind.Sequential )]
public struct KeyValuePairThatSerializesProperly<TKey, TValue>
{
private TKey key;
private TValue value;
public KeyValuePairThatSerializesProperly(TKey key,
TValue value)
{
this.key = key;
this.value = value;
}
public override string ToString()
{
StringBuilder builder1 = new StringBuilder();
builder1.Append( '[' );
if ( this.Key != null )
{
builder1.Append( this.Key.ToString() );
}
builder1.Append( ", " );
if ( this.Value != null )
{
builder1.Append( this.Value.ToString() );
}
builder1.Append( ']' );
return builder1.ToString();
}
/// <summary>
/// Gets the Value in the Key/Value Pair
/// </summary>
public TValue Value
{
get
{
return this.value;
}
set
{
throw new NotSupportedException();
}
}
/// <summary>
/// Gets the Key in the Key/Value pair
/// </summary>
public TKey Key
{
get
{
return this.key;
}
set
{
throw new NotSupportedException();
}
}
}
}

Having done that, to add a little clarity when using this class in the way I anticipate and eliminate repeated code, I decided to create some specific versions of the Collection, ReadOnlyCollection and KeyedCollection classes:

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace IanFNelson
{
[Serializable()]
public class KeyValuePairCollection<TKey, TValue> :
Collection<KeyValuePairThatSerializesProperly<TKey, TValue>>
{
public void Add(TKey key, TValue value)
{
this.Add( new KeyValuePairThatSerializesProperly<TKey,
TValue>( key, value ) );
}
}
}
using System;
using System.Collections.ObjectModel;
using System.Collections;
using System.Collections.Generic;
namespace IanFNelson
{
[Serializable()]
public class ReadOnlyKeyValuePairCollection<TKey, TValue> :
ReadOnlyCollection<KeyValuePairThatSerializesProperly<TKey, TValue>>
{
public ReadOnlyKeyValuePairCollection(
IList<KeyValuePairThatSerializesProperly
<TKey, TValue>> list) :
base( list ) { }
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace IanFNelson
{
[Serializable()]
public class KeyValuePairKeyedCollection<TKey, TValue> :
KeyedCollection<TKey, KeyValuePairThatSerializesProperly
<TKey, TValue>>
{
protected override TKey GetKeyForItem(
KeyValuePairThatSerializesProperly<TKey, TValue> item)
{
return item.Key;
}
public void Add(TKey key, TValue value)
{
this.Add( new KeyValuePairThatSerializesProperly<TKey,
TValue>( key, value ) );
}
}
}

You learn something new every day

0

I promised Jocelyn I’d blog about the fact that, whilst out shopping in York yesterday, my dear wife taught me a new verb, noun and adjective!

iTunes 7

0

More funky software released this week – iTunes 7.0.  The most noteworthy new features are its native ability to download missing cover art from the iTunes store for tracks in your library, and the “Cover Flow” option of browsing through music by flicking through the cover art:

iTunesArt
 
iTunes3
 

But other aspects of the UI have had an overhaul, with new screens showing download progress and device summary:

iTunes2
 
iTunes

Office 2007 Beta 2 Technical Refresh

0

I hadn’t exactly been waiting in eager anticipation of the release of Office 2007 Beta 2 Technical Refresh, as I was under the impression that it was a minor update being released purely for compatability with Vista RC1.  But John emailed the download link to me on Friday morning, and I duly installed it, and I have to say, I’m glad I did.  There have been a shedload of UI improvements, and the whole suite feels much more stable (by which I mean that Outlook doesn’t crash on me half a dozen times a day any more).

If you’re running the beta 2 release, I’d certainly recommend installing this update.
You’ll also want to grab yourself an updated copy of Windows Desktop Search while you’re at it, and the Save As PDF add-in which (thanks to Adobe’s lawyers), can no longer be included out of the box.
Oh, and if, like me, you’re running Norton Antivirus, you’ll probably have to disable its Office Plug-in, or face being unable to open any Office documents!

Applying Domain-Driven Design and Patterns

0

People often ask me how my commute is since we moved house.  It’s pretty good.  For one thing it’s 33% shorter in raw distance terms, but due to no longer having to battle my way through the centre of York, combined with the benefits of the recent A1 Darrington to Dishforth project, I can get to and from the office pretty quickly on a good day, arriving bright and early for a full day’s coding :-)

This shortened journey time means I no longer listen to quite so many podcasts – in fact the only ones I subscribe to now are Hanselminutes, From Our Own Correspondent, and of course Dot Net Rocks.

Now, some Dot Net Rocks episode titles excite me more than others, but I was quite interested when I saw that a recent episode featured Jimmy Nilsson, as I have recently been enjoying reading his book "Applying Domain-Driven Design with Patterns with Examples in C# and .NET".  What a shame, then, that this particular episode of DNR was so dull.  I realise that DDD and patterns can be a pretty dry topic, and of course one has to remember that English isn’t Jimmy’s first language, but even so, he could have tried to sound more interested in the subject matter!  I felt that Carl and Richard were straining to tease out interesting thoughts and anecdotes, only to be provided with the shortest of answers to their questions, along the lines of "Yes, I am in agreement with that". 

Hey ho.  But hey, don’t let me put you off buying Jimmy’s book, it really is a good read.  It draws on two of my other favourite books, Patterns of Enterprise Application Architecture and Domain Driven Design, but also includes sections on Test-Driven Development, Refactoring, Aspect-Oriented Programming, Service-Oriented Architecture, NHibernate, etc.  Plus, as the title says, all the code examples are in C# and .NET (my tools of choice).  If you’re a .NET developer, and only buy one book this year, make it this one.

Updated 2006-09-14 0932:
Humph.  I should learn not to boast about my improved commute – my 33-mile journey took me 130 minutes this morning due to an overturned lorry on the M62.  Makes Rosie’s Brazilian bus trips seem positively speedy!

Virtual faces

0

So, on Friday Jocelyn and I had dinner with Nat and Pam (and very nice it was too, thanks!).
Nat came out with a classic quip:

“I have a terrible memory for faces.  It’s always a surprise to me when you don’t look like your MSN picture.”

Which made me laugh – it’s a reflection of our times, but also the geeky nature of a large part of my circle of friends that we spend more time communicating through MSN and Google Chat than IRL.

For the record, my current MSN pic looks like this:

Me

Whereas my most recent passport photo looks like this:

Also Me

I don’t think they’re all that different…

The First Day of School

1

Ah, the first day of a new school year… the nation’s kids return to education, and my commute time doubles overnight :-(

The First Day of a New School Year

Page 1 of 212»