Blog Stats
  • Posts - 25
  • Articles - 0
  • Comments - 10
  • Trackbacks - 36

 

Is the Singleton Question such a difficult one to answer

I do a lot of interviewing in my role, and one of the first questions I ask when interviewing a candidate is

What is a Singleton?

Most candidates get it right, A class where only a single instance can be created, if the candidate does not get the right answer, I explain what it is, as not eveyone is a pattern geek, even though this is one of the most common and well known patterns.

What I ask next, is to provide a minimal implementation, in the language of choice ( most cases its one of the following, Java, C# or C++ ), now this is where it starts to get interesting.  The following is an example of one recent candidates answer, they wrote this on the board with a straight face

class Singleton {

public int count;

}

This caused much discussion between the candidate and myself, obviously they did not understand anything about the C# language at all, and the concept of a private constructor was completly foreign, I then had some fun for the rest of the interview watching the candidates facial expressions as I asked more simple questions, about his implementation.

FYI

Nice Solution to the Singleton question using C#


Feedback

# re: Is the Singleton Question such a difficult one to answer

Gravatar I hope U didn't hire the candidate based on the above whiteboard session. During interviews, we use a lot of algorithm and data structure questions. 1/6/2005 6:32 AM | Matt

# re: Is the Singleton Question such a difficult one to answer

Gravatar Please send me most difficult questions on Java and Dot Net. 12/23/2008 8:54 AM | Nandu Kewate

Post a comment





 

 

 

Copyright © David Lattimore-Gay