I've come to believe that the best way to interview a developer is to pair program with them, giving them a problem in their technical strength and being a questioning, supportive pair partner in order to see what their best is. And I want to make it a good experience for the candidate. The things I look for in a pairing session include, of course, TDD. Besides gauging their skill, I am looking for things like how they handle difficulty, if they can accept direction, how they handle disagreements, if they are curious, if they are careful and detail-oriented.And I want to see if they can have fun while working on something.
If the candidate is not strong at TDD, I can help them learn and leave them with suggestions and resources on how to improve if they would like to apply again.
If the candidate is good at it, we can talk about TDD styles, or code patterns, or architecture or really anything relevant to the position. I'm looking to see their curiosity, and what they would. be like to work with.
Recently, a client asked me to participate in a panel interview for a senior developer they were considering. The panel was a mix of non-technical and technical people, so no pair programming was going to happen. I got to thinking how hard would it be to gauge whether a person' was good at TDD if their resume listed it as a skill. I proposed this to a colleague, D., who is learning TDD and we decided to see if I could do it. Here's a slightly edited transcript of what we did over instant messaging:
Jeff Hoover
Imagine you are Test Driving new functionality, say adding a student to a course, and I can't see your screen. Describe what I would see as you go from first test to first implementation to second test to implementation.
D.
I'd tell you that I'm assuming that the student and course classes exist, so that I don't have to go through the exercise of creating the "data bag" classes. Then I'd tell you that I am going to assume that I'm creating a service class that will sit behind a controller or some other "exposing mechanism" so that I'm not having to deal with that nonsense...
Jeff Hoover
OK. So what do you type first in your editor?
D.
then I'd probably tell you that I'd start with a JUnit test case, and I'd say that I'd have a testAddingAStudentToACourse test method. I'd tell you that.
Jeff Hoover
What goes in the test case?
D.
So the first thing that I do is something like: boolean studentAdded = registrationService.add(new Student());
(EDITORIAL - I would really like to hear: "To make sure my framework is configured properly. I'd write a test with assertTrue(false) , run the tests and see it fail, then I'd delete the test." Lack of this remark doesn't prove anything, but if they say it it gives me confidence in their experience with things that might go wrong, and that they can think about a process and describe it well)
Jeff Hoover
Does your test case compile? (Ed: I wish I'd figured out a way to get at this without handing to him. His answer doesn't give me much)
D
Nope. So now I let the IDE generate the RegistrationService class. Once that happens (and the add method is created as well) then the test fails.
(Ed. I probably should have asked why the test failed, to get at what assertion he had.
Jeff Hoover
Bonus point for IDE automation!
D.
Then I implement registrationService.add(
D.
Then the test passes.
D.
Now for the next test, I realize that I've added a student, but haven't specified what course to add them to. So now need to refactor the test and the class to add them to a course. So now I have in the test: boolean studentAdded = registrationService.add(new Student(), new Course());
(Ed. If I had asked: "let's say you don't have a Course class - would you stop working on the Service and take a side-track to TDD the Course, or stay with the Service and added tests to the Course as needed?", it might give a senior dev a chance to comment about outside-in vs inside out)
D.
Now I need to test that the course contains the new student after I register the student. At least I think that's the right thing to do...
D.
That's the next smallest test that I can think of...
( Ed: Nice! Candidate has shown me a basic ability to TDD. If they were applying for a junior position, this would go a long way towards receiving an offer. Candidate has the basics. They will hone their skills when they pair program with senior developers on all their cards. For a senior position, more conversation would, of course, be necessary.)
D.
I now have to look at whether or not the registration should return a boolean or an altered course object. I'm gonna go with the latter. So now, I change the return types, etc...
No comments:
Post a Comment