Darren posted up an entry about using metadata and reflection to dynamically manage message routing. Its an elegant solution and an example of where attributes can be used to perform a mapping function. Geoff and Scott chimed in with their feedback.

I was fortunate enough to see Darren apply this technique to the actual problem domain (the message routing thing is just a disguise) – in that instance it worked really well because the code didn’t live on the server-side – it was client side so thoughput was not going to be an issue (possibly wouldn’t have been anyway – even with reflection).

The thing about reflection is that it gets cheaper (relatively speaking) to closer you get to the end user where is typically a dedicated processor core. So if you can use reflection in a windows client application to improve maintainability and clarity in the code base then you can probably do so safely – but you should always test.

Oh – and Geoff – for the record Lutz Roeder’s Reflector doesn’t actually use .NET reflection to pluck apart assemblies – he has his own unmanaged library for doing that – in fact you don’t even need .NET installed.