Great Interview Exercise: Object-Oriented Awareness

Though I am now employed, the past few months have been illuminating with respect to the interview process. There is so much disparity between what employers are asking for in their job descriptions and what they actually do to evaluate the requirements that they claim they need in candidates. The most interesting thing I’ve run across is a requirement for MVC or object-oriented JavaScript. However, in about 90% of the interviews I’ve had, very little has been discussed with respect to general object-oriented principles, let alone object-oriented JavaScript. In fact, most interviewers simply ask if I know certain MVC frameworks such as “backbone” or “knockout.” When I’ve gotten those questions, though I answer that I am familiar with them, but have never built anything with them, I think to myself that the the interviewer is going to be entirely tactical with the interview, and only brush the surface of OO JavaScript.

I’ll just say it plainly: Just because someone happens to know a particular MVC or OOP framework doesn’t mean they actually understand OOP. No matter what framework you use, OOP is all about design, all about understanding the relationships and interactions between objects. Go ahead and make all the objects you want. But unless you have a clear idea of how they relate and interact, then you run the risk of doing A LOT of extra coding down the line to compensate for your lack of design. Mind you, I’m not just throwing this out as a matter of opinion, I’m coming from a position of experience.

Circling back to the crux of this article, that’s not to say that there haven’t been some great interview questions or exercises that cover OOP. There have been. But one in particular stands out above the rest, and it will be an exercise that I will use going forward. I got this from a great interview with a little company called Urban Mapping with which I interviewed a few weeks back. It was the first time I felt that a company “got it” with respect to object-oriented design. And you know what? The exercise had very little to do with JavaScript. Their thinking behind this exercise is that it’s more important to know the architecture behind what you’re building before you build it. AMEN TO THAT! So without further ado, let’s get into the exercise:

Let’s Build an Animal Kingdom

Given the following animals:

Dog, Cat, Eagle, Duck, Python, Anaconda, Iguana, Salmon, Lungfish, Frog

Build an object hierarchy that can describe this set of animals. After you’re done we’ll discuss. There isn’t necessarily a right or wrong answer to this. But we’re going to take this time to discuss your object-oriented awareness and acuity.

Here’s a possible solution to this hierarchy:

Once they’ve finished the diagram, you get into the application of the design. Note that this is not to be confused with implementation, but rather, providing a context to the design to see if there are any holes in it. But first, some questions:

  1. What was your reasoning behind building the hierarchy in this way?
  2. Would there be another way to approach this? (Another possibility would be to break it down by number of legs, but that is actually not optimal based upon the follow-up exercise of creating a world for the animals)

So the context we’ll use is this: Building a world to place the animals. So on the board, draw out an area that has a body of water, some trees, maybe a cloud to represent air, and some rocks. After  you’ve drawn it out, then say that we’ll instantiate these animal objects in various places on the board. The idea is to reveal if the design will support the constraints of the environment. If they broke down the hierarchy according to number of legs, they may have missed the functional level. This is something that can be suggested and will almost immediately be revealed once you start going through instantiation.

If they did break it down by function, then chances are they will have missed the multiple inheritance. For instance, an anaconda can be created either in water or on land; same with the dog. You can lead them through this with some questions:

  1. Is it possible that an animal can be instantiated in different locations? (You’ll especially look to see that the duck can be instantiated as a swimmer, walker, or a flyer). That last bit was a little evil on my part. 🙂
  2. Given that animals can be created in a couple of possible locations, and that there constraints as to where they can be created, where would you place the method that would check for the location? The correct answer would be at the second level, so that those animals that inherit from two parents will inherit the location constraint from both.

Summary

So in this exercise, what are we trying to accomplish?

  1. The obvious answer is to see if they get object-oriented design at all.
  2. The second thing this reveals is how well the candidate can communicate and justify their ideas.
  3. And just as importantly as the other two, this exercise reveals if this person has the ability to work with the team.

Note that this exercise is best done with a couple of people in the room – probably no more than three – especially to address item 3 above.

Based on my experience on the receiving end, doing this exercise was literally a breath of fresh air. Personally, I wouldn’t pull this on a junior developer, but this is something that I’d definitely use for senior front-end AND back-end developers. Remember, it’s not about the code with this exercise, it’s about the design thinking. Do a separate coding interview following this.

Update 7/2020

I’ve been using this for over ten years now and it is still one of the best ways to weed out code monkeys. If a candidate can’t get through this exercise, then it’s a fairly clear indication that their code is likely going to be a mess. It just proves out that just because you code in an object-oriented language doesn’t mean you know OOAD/OOP.

This has been especially effective in evaluating front-end developers; especially those developers who claim to be senior but their experience has been strictly limited to frameworks such as React or Angular. It doesn’t necessarily mean that I will reject them entirely, but it will affect where they’ll be placed in the engineering organization.

Advertisement

2 thoughts on “Great Interview Exercise: Object-Oriented Awareness

  1. Pingback: Keys to Finding and Hiring Great UI Engineering Talent « Welcome to my dawg house!

  2. Pingback: Keys to Finding and Evaluating Great UI Engineering Talent « Welcome to my dawg house!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s