Controller Action Design in MVC

Validate, Act, Translate, and Respond. That’s about it. I’ve been trying to come up with a nice acronym for how to structure code in Actions for some time now, and this is the best I have managed. I wish it spelt a nice word – so if you’ve a better suggestion shout up. What I’m…


What on Earth is a Lambda Expression?

Recently I’ve spoken with a few customers that have asked what a Lambda Expression is, which surprised me. It seems that a second wave of developers  are now starting to use Lambdas (i.e. those that didn’t adopt C# 3.0 immediately) and need some pointers, so this post is intended to help you understand what they…


String.Unformat: I’ve created a monster

I don’t know if you’re the same, but when coding away I often find myself wishing for a String.Unformat function – call it the evil twin of String.Format. With String.Format I can build up strings like this; var result = String.Format(      “http://{0}:{1}/{2}”,      “localhost”,      “12345”,      “TestPage.aspx”); … which will return “http://localhost:12345/TestPage.aspx“. But…


foreach keyword or ForEach<T> extension method?

Is this a question of taste, or something more serious? [Warning: this post won’t change your life J] I found myself writing the following extension method yet again the other day; public static void ForEach<T>(     this IEnumerable<T> source,     Action<T> action) {     foreach (T item in source)     {         action(item);     }…


All About Lamdas

I’ve been reading Mike Taulty’s blog for ages now, and I love his balance of technologies, the length of his posts, and his style of writing. So if you’re not a subscriber, go check it out. But I just had to draw attention to his recent post – “Anonymous Methods, Lambdas, Confusion”. It’s a well…


Lamba Expressions to the Rescue!

Maybe I’m biased because he’s on the same team as me (ahem, sorry for the plug J), but I really liked Stuart Leeks’ post on improving the “Include” method on ObjectQuery<T>. It’s another example, like the MVC Framework he mentions, of how lamba expressions can be used in the real world to add type safety…


Strongly Typed Primitives

No, I’m not talking about NEANDERTHALS (there’s a joke in there somewhere), but rather a technique that a colleague of mine, Josh Twist, has recently blogged about – “Avoiding Primitive Obsession to tip developers into the pit of success”. I’d always seen a pit as symbolic of failure, so I’m pretty pleased there’s such a…


C# "var" Keyword: We Need Your Vote!

Josh Twist is running a vote on the use of the “var” keyword. Get voting! Oh, and make sure you vote “var is for anonymous types only” or he’ll never let me live it down. Ever. I’ll be watching J  


Aspect Oriented Interception

Have you used Aspect Oriented Programming (AOP) or Policy Injection? They’re pretty much the same thing. If you haven’t, I’d highly recommend doing some reading, as I believe it is a Software Engineering practice that has moved out of the “fashionable” and into the “enterprise”. For separation of concerns it is a fantastic paradigm. I’ve…


Self-Referencing Generics: Follow-up

After being prompted by a friend (or ex-colleague, or drinking buddy, whatever you want to be called J) I think I owe further explanation about my previous post on generics. Consider these two classes; public class FirstClass<T> {     public FirstClass<T> Parent; }   public class SecondClass<T> {     public T Parent; } Now, if…