I'm aiming to kick off the new year with a big development push next year and as part of this initiative I'm hiring some new staff. I've been reading a great book (I could even call it my new Bible :)) on software develement management called "Joel on Software", written by Joel Spolsky. He's suggested a format for interviewing which he's refined over the years to ensure he hires only quality staff. Or as he puts it "Smart people that get things done", as opposed to just smart people, or just people who (appear) to get things done.
I was previsouly using many of Joel's suggested techniques, but suprisingly not using the perhaps the most important. I hadn't been getting candidates to write actual code as part of the Interview. I've since discovered that writting code during an interview is paramount to getting quality employees. I'm not claiming that it's the only thing but I do believe without it you haven't got a chance.
My code question is quite simple, even more-so than Spolsky's problem of writting a function that reverses a string in-line. I ask the candidates to write a function that reverses a string in C# (or VB.NET). I choose C# because we're hiring only .NET developers. If they have never used C# I'll allow VB.NEt, simply because it's so closely related to C#.
I expect to see something like:
public static string Reverse(string input)
{
char[] temp = new char[input.Length];
int len = input.Length -1;
for (int index = 0; index < input.length; index++, len)
{
temp[index] = input[len];
}
return new string(temp);
}
I didn't have even one candidate who could produce this. The last candidate (and if his references check out, new employee) nearly had it, in VB.NET, but his syntax wouldn't have compiled and he added strings together. Looks okay, but the problem is that strings are immutable and a new instance needs to be created each time you call Substring(), or join two or more strings together, as was happening every iteration. Using Substring does have one benefit though, it's aware of surrogate pairs, which my implemenation above is not. The most annoying thing about this question (and the responses I got), was that when I asked my brother to do it he did it in 1 minute, in C# and it was right. Every candidate I interviewed had AT LEAST a Masters level IT degree, yet my brother could manage it, aged only 19 and with a Cert IV in IT.