Steven's profileDevelopmentalBlogLists Tools Help

Blog


    May 29

    Contravariance, Covariance, and Generics

    The common question is: what the hell is contravariance and covariance?

    Ok so you are familiar with casting right? In C# we can do this:

    public class Animal { }
    public class Monkey : Animal { }
    ...
    Animal a = new Monkey();
    ((Monkey)a).FlingCrap();

    We can also do this:

    public void MoveWest(Animal a) { }
    ...
    MoveWest(new Monkey());

    Because the 'MoveWest' method accepts the narrowing type 'Animal' it is said to support 'Contravariance'. If the C# compiler forced us to only pass exact types, then it would be considered 'invariant'. Likewise C# methods support covariance, in that we can return a narrower type and cast the resulting instance to its correct form.

    There are parts of the .Net framework however that aren't so flexible. In this case, I'm talking about generics.

    Consider this for example:
    List<Monkey> monkeys = new List<Monkey>();
    monkeys .Add(new Monkey());
    List<Animal> animals = monkeys;

    Unfortunately this does not compile. We get the following warning:

    Cannot implicitly convert type 'System.Collections.Generic.List<FeaturesCsharp2.Monkey>' to 'System.Collections.Generic.List<FeaturesCsharp2.Animal>'

    Why is this? Monkey inherits Animal, so the list conversion is perfectly safe. Well this is one case of invariance. But here's the kicker: word on the street is that the CLR actually supports contravariance of generic lists; its just the C# compiler that doesn't!

    Circle Of Interest

    My mate and fellow Readifarian Paul Stovell recently posted his 'Circle Of Interest' and started a meme by nominating 5 others to do the same. I was one of the lucky ones, so here's my circle.

    Corethings

    I don't doubt this circle will change completely in 6 months. I expect the TFS parts to fade into the middle circle, with more focus on WPF and SilverLight perhaps. Who can tell?

    The big red circle indicates things I don't care about, the baby-vomit yellow indicates stuff I am interest in but have little time or dedication to fully pursue. The dog-vomit green is the stuff that I am loving working or am most eager to develop as soon as possible.

    Oh, WCF shouldn't be in the middle circle, but I couldn't be bothered changing it.

    Now, to continue the meme, I nominate these people:

    Matthew Rowan , John McFadyen , Joseph Cooney , Leon Bambrick

    Get to it chumps!

    May 05

    Personal Development Plan

    At Readify we are encouraged to do a plan that we can use for guidance in our personal development. I was pretty generic with mine and have decided to give it more focus today (given that its labour day and all). I figure I'd post it here so that I can hold myself accountable to it next year. Lets say, end of financial year 09? Gives me 14 months to see what I can achieve off of this list. Naturally having a baby will affect this in yet to be discovered ways.

    The list is priorities by importance for high level headings only. Its mostly just a bullet point list, which is interesting because I am unsure how to measure success for some of these things (for example, when will I 'know' WCF? I've done a bit already but still am not across all the security aspects).

    Anyway, here's the list. Feel free to critique or post your own list in response.

    Certifications (importance: HIGH)
    · MCTS: Web Applications
    · MCTS: Windows Applications
    · MCTS: WCF
    · MCT: Certified Trainer
    · MCTS: Business Intelligence

    Improve blog quality (importance: HIGH)
    · Attract more readers
    · More diverse topics (as my knowledge increases)
    · More frequent postings

    Specific Technologies (importance: HIGH)
    · LINQ, dLINQ, xLINQ, etc
    · SilverLight
    · Expression tools
    · Windows Presentation Foundation
    · MVC Framework
    · ADO.NET Data services
    · ADO.NET Entity Framework
    · Windows Workflow Foundation
    · Windows Communication Foundation
    · Active Directory, DNS, and networks
    · Sharepoint
    · Intermediary Language
    · Team Foundation Server / Team Build
    · Visual Studio Team System
    · ASP.NET Ajax
    · Business Intelligence
    · Reporting Services
    · BizTalk
    · Integration Services

    Attend Special Interest Conferences (importance: HIGH)
    · Tech Ed - Australia
    · ReMix - Australia
    · Mix - United States
    · Tech Ed – Europe

    Presenter (importance: MEDIUM)
    · User groups / SIGs
    · Code Camps
    · Tech conferences like TechEd

    Further Study (importance: LOW)
    · Physics/Chemistry/Astro-physics
    · MBA

    Author (importance: LOW)
    · A technical book, unsure of topic at this stage
    · Articles to MSDN, code magazines, etc

    Wow, looking at this list, I feel like I know absolutely nothing! But to be honest, I have groundings in a lot of the technical stuff (like SilverLight, WCF, Reporting Services, BI, LINQ, etc), but I really want to gain expertise in these areas.

    Why do I rank certifications so highly? Well I'm keen on the MCT, which requires an MCTS or two. Also they are useful to an employer for points towards partner status. Finally, its a personal milestone, ie the certification is for me, not you. I want to pass all those tests based on my knowledge (not cheating, examining practice tests, etc).

    I don't expect I'll get to Tech Ed Europe or Mix US anytime soon, but ReMix is a possibility for me this year (I've never been) and Tech Ed is a definite (see you there!).

    May 02

    So You've Ruined Your Life...

    You might recognise this quote from the Simpsons as the title of the book that doctor Hibbard gives Homer and Marge after they realise they are 'up the duff'.
     
    Since I just got the news that my wife Sonia and I are now also 'up the duff' I figured it would make for a good article title. I don't actually believe it of course... I'm as excited as a little kid with a lollipop! It will however mean that my lifestyle will change somewhat, since I now have new priorities.
     
    So that's all this article is about. Its been just the two of us (married for over 6 years) and a sausage dog up until now. I'm excited, curious, and nervous, all rolled into one. I have no idea how it is affecting my work, but no doubt this will change me in ways I have yet to understand.
     
    Anyway, I just want to apologise for the lack of blogging in the last few weeks, and hopefully I'll be back at it again soon.