Wednesday, August 27, 2008

My Favorite Inverview Question

In a recent discussion interview questions came up, here's my favorite one.

To set some context this question is designed to gauge the abstract and critical thinking of a generally inexperienced developer. I don't usually use this for very experienced developers, but may if I think I'm getting shallow or suspicious answers.

Here's what I start with:

I'm friendly but not at all helpful while I do this.
  • I draw it out by hand on a whiteboard or on paper
  • I verbalize the relationships
  • I offer to explain the notation and meaning of "is-a"
  • I ask them to think out-loud
  • I hand them the writing instrument
Then I just ask the candidate for their impressions of the model.
  • What's good? What's bad? What would you change?
A few obvious things that the candidate should work their way around to:
  1. A "Deer" is an animal also.
  2. A "Cow" could be "Food" for a "Tiger".
After watching them squirm for a while, I then make one addition to the original model. I add a single method/operation to the "Animal" class.
Again, I ask them for their impressions.

If they don't get to it themselves I make sure to ask the following questions:
  1. What happens if a "Deer" is passed to the eat method of a "Cow"?
  2. How would you change the model to handle or avoid that problem?
Enjoy!