A Simple Audition for Developers

I was speaking with a colleague the other day, and he told me about an audition he’s been using for developers for years: asking them to implement a String-Copy function in the language in which they’ll be developing. Some of their reactions are telling:

  • Some have said, “Why? The language has it?”
  • Some have worked for 20 minutes, and figured it out.
  • Some have worked for over one hour and not figure it out.

My colleague’s reply to the “Why?” people is to explain he’s looking for an example of their language skills. Only one person walked out of the interview.

For the people who finish in under an hour, they discuss how this version works. In fact, some candidates realize they have performance problems with their code during the walkthrough, and then want to change it.

Some people freeze, or just can’t figure it out, so for the people who work for an hour but can’t get it — and want to keep working — he says, “Go home, figure it out, and email it to me.”

What my colleague is looking for is simple: does the person know the language well enough to write something that he or she is willing to discuss with something else. It doesn’t have to be perfect and it doesn’t even have to be right. My colleague has to see just a little evidence that the candidate has thought through the problem, has tried to implement something, and has checked his or her work. Brilliant!

Over the years, my colleague has kept the implementations on these pieces of paper, and he was surprised by how many techniques a person could use to implement a String-Copy. (I’m not 🙂

For whatever jobs you’re hiring, think about how you’ve asked the candidates to show that they have thought through the problem, tried to implement something, and has checked their work. That’s an audition, and it’s especially good if most people can solve the problem enough to discuss their implementation in about 20-30 minutes. That’s because many people become nervous or resigned if the problem seems overwhelming or impossible.

8 Replies to “A Simple Audition for Developers”

  1. I like the idea of a developer audition as part of the interview process. The String-Copy example has a nice balance of complexity and pit falls against time. But it is a very C style question and doesn’t really make sense for languages where strings are a first class object. e.g. in Java you wouldn’t copy a string because they are immutable, so it would be silly to make a copy. But if you had to make a copy you could do:
    String original = “original”;
    String copy = new String(original);
    or a bit more perverse
    int len = original.length();
    char[] copyBuffer = new char[len];
    for (int i = 0; i < len; i++) { copyBuffer[i] = original.charAt(i); } String copy = new String(copyBuffer); or String copy = String.copyValueOf(copyBuffer); or course this is wrong because it will throw an exception: String copy = original.clone(); But for me the correct answer for write a string copy in Java is, there is no need because strings in Java are immutable. Which brings me to my question, have you come across any similar questions for Java that would be suitable for an interview?

  2. I wonder how much of the success of this question depends on the language. In C this is (or should be) easy. In Perl you might get into some functions that a lot of people spend their entire professional lives never touching (substr?).

  3. I think it’s a great Java question — look at all the potential solutions Miles came up with.
    The fact that candidates get an hour to work on this makes me feel like a genius. 🙂

  4. I think one more thing that needs to be added is the “ability to design with the langugage”. Questions like string-copy are great to find out if he can work with the langugae. Next should be if one can design with the language?
    Ex design scenario::In our organizaion sales managers are given targets under different goal heads. At the end of every month they do submit the actuals vis a vis the expected.
    Tell me how will you implement this feature : “calculating monthly targets” in say::java, ruby,..c# whatever?
    Answers are illumintating. 🙂

  5. I had an interview when I was asked in java to write on a piece of paper the “hello, world” program in java. I responded with the “Why?” question as well, and the interviewer said that many appliants cannot write it without and IDE.
    I offered to try and throw in some complexity for complexities sake just so I could show off a little, but she just wanted to see the program.
    Of course the Big O notation part didn’t go over so well. 🙂

  6. Jason I agree there are several potential ways to do this in Java but I don’t want to force the developer to come up with solutions that would otherwise fail a code review. In Java you shouldn’t copy strings, just pass the same reference around. If I saw any of those snippets in actual production code, I would be concerned about the developer’s understanding of strings in Java.
    A spin on the question would be to present several string copy solutions and ask them to say which one is best, but then it becomes a bit of a trick question.
    A problem I’ve had coming up with short, yet potentially deep, questions in Java is the amount of dependency on libraries. Every programming question in Java comes down to what library you choose to use, the trick is not to turn the question into a rote-memorization of the APIs.

  7. Hi JR.
    I spoke to you at SPIN. Nice talk.
    Thanks.
    over an hour?!?!ok just make a point, it is a single line of c code
    void cpy( char* d, char* s){ for(;*d = *s; ++d, ++s); }
    ingnoring the 3 to 5 easily checked error conditions…which is important since this kind of code was responsible to the buffer overflow attacks awhile back
    but over an hour? yeeessh
    when I do interviews though I tend to make my questions a lot harder. I have had people walk out.
    I am not being mean.
    Its just that there is about a 10x productivity difference between the top %25 of developers and the bottom %25.
    here are some hard questions
    given two dates(day, month,year), how many days are there between them
    sort a list of numbers. The list is larger then can fit in ram
    implement a binary search on a list of integers
    implement the game Scrabble…
    but these are too hard for phone screen. Any good ideas for a quick phone screen questions?
    The other area I was looking to improve was easy ways of figuring out teamwork, good people skills, chemistry…not sure it can be tested
    other then by trotting the canidate out in front of the other team members… a lot of work that way though.
    Karl

Leave a Reply