Tuesday, September 16, 2008

Favorite Interview Question (Part 1)

What makes a good interview question?  Clearly it should allow you differentiate a hire candidate from a no hire candidate.  That's fine but how do we do that?  I am a fan of the Joel approach basically Smart and Gets Things Done. Once again that fine, but what does that mean.

I'll start with the Gets Things Done part.  This is a very important part of a candidate, but for me it is kind of a one sided interview question.  Its just a check box you need to check.  The reason is it is hard to get first hand evidence in an hour, or a day, of interviews that a candidate will get things done.  The best you can do is use some behavioral interviewing and get examples of situations where the candidate has Gotten Stuff Done in the past.  

Which is great and all.  But if we assume the person is as smart as I hope they are, then it is pretty possible that they are able to make this whole part up.  Now clearly you want to ask probing questions into the details of the situation, which is all fine and dandy.  But I still assume a good candidate could make it all up.  So the moral of the story is the only thing you can do is rule your self out in the Gets Stuff Done  part of the interview.

So assuming they don't screw up the Gets Stuff Done part how do assess smartness.  You don't want a question that has just a right or wrong answer, or that requires a burst of insight to figure out.  Those types of questions don't allow you to get any insight into the candidates thought process or ability to assimilate new information into their solution.

I am also a believer that if you are hiring a person to code, you should probably see them code.  Makes sense when you say it, but I still see some people asking logic questions that are only marginally related to programing.

A pet peeve I have about interviews and coding questions is the medium.  Are you hiring the person to write code on paper? On a white board? To just talk about code?  No you are hiring them to type out code in an IDE.  So have the interview set up like that.  Let the person code in an IDE they are used to.

So that is everything about my Favorite interview question but the question, which seems like a good place to stop part 1.  Hurry back for part 2 to find out the question.

Sunday, September 7, 2008

NullReferenceException and Extention Methods

Where does this test fail:


   29         [TestMethod]


   30         public void TestMethod1()


   31         {


   32             Foo a = null;


   33             Assert.AreEqual("a", a.DoIt());


   34             Assert.AreEqual("a", a.ToString());


   35         }


Line 33 or 34?  Or can't you tell?

You can't tell, if DoIt is defined as a member function, then it fails on 33.  But if DoIt is an extension method then it fails on line 34.

This makes sense if you remember that extension methods are just syntactic sugar and really it gets compiled into function calls to the static function so you don't actually need to have a reference to the real object.

Null Coalescing

I like to think that I have a decent understanding of the C# language, so when I found out that there was an operator that I didn't know about I was shocked. There are some operators that I don't use a whole lot (%=, >>=,<<=) but one that I had no idea about, I was shocked. ??, the null coalescing operator.



var y = a??b;



y is a if a is not null, if a is null then y is b.

Straight froward enough, and fairly usefully. I found two usages for it the first day I learned about it. So I took a quick poll around the workplace, and it turns out that ?? wasn't known by anyone I worked with. So why is it, it usefully and easy to use, it isn't new to 3.0, so the only thing left is that it doesn't have a good name.


Null coalescing sounds like something a printer does. "Question mark question mark" is about 4 syllables too long. So from the references guide
some choices might be "quiz quiz", "query query" or "button hook hunchback". But I suggest that we standardize on "huh what". It might cause confusion at first in code reviews, but I think at 2 syllables, and some flare it is the best choice. I am going to start the movement to standardize on the "huh what" nomenclature, I hope you will help me out.