The Pinball Model Interview Question

June 19th, 2010

A engineer I used to work asked me my thoughts about an interview question he received recently. The question was essentially, “How would you model a pinball machine as a program?” This is a classic object oriented programming (OOP) design question. As with any design question, there are an unlimited number of approaches. Let’s imagine that you further qualify the question and determine that you want to model the software for a physical pinball machine, rather than, say, model the software for a pinball simulation. Additionally, you sketch out a pinball machine of some sort to establish things like how many players there are, how many balls each player gets, and so on. First we would identify each component of the pinball machine: bumpers, playfield, flippers, spinners, and so forth. Each of these would correspond to a class. For example, in C#, a bumper object might be modeled something like:

public class Bumper
{
private string id;
private int pointValue;
private int reboundStrength;
// etc.
public Bumper()
{
// constructor code
}
// properties here
// methods here
}

The interview question really boils down to, “Explain OOP principles to me using a pinball game as a concrete example.” So, the interviewer wants to know about classes, constructors, data fields, scope modifiers, properties, and methods. Additionally, you would want to discuss the pros and cons of creating abstract base classes and using inheritance. A question like this could come in many forms. For instance, “How would you model a vending machine?” Or, “Model a poker game for me.” All of these questions are the same in the sense that they’re intended to determine the candidate’s experience with OOP. Familiarity with object oriented programming is not a Boolean, has-it-or-doesn’t-have-it, kind of thing. The interviewer is looking to see exactly what level of familiarity with OOP the candidate has.

Entry Filed under: Interviewing


Calendar

September 2010
S M T W T F S
« Aug    
 1234
567891011
12131415161718
19202122232425
2627282930  

Most Recent Posts