views:

4392

answers:

18

Smart interviewers for positions that require programming ability actually get applicants to write a short program, equipping them with PC etc.

However what should the test program do as a reasonable test with a time limit of about 30 minutes. [Answers should be the required program specification.]

If you are an interviewer, what do you ask your candidates to do and what are you looking for in their answers?

If you have taken such a test recently, what were you asked to do, and do you know what they were looking for?

I'm particularly interested in C# .Net related questions? Also model answers might be interesting.

Please use voting to rate which tests are most suitable for this role.

+2  A: 

Firstly, you should only test 'performance' here, and not worry about design.

I suggest you give the developer a 'broken' project with a test suite. See how well he can make all tests pass. As a bonus make a broken test too, so you know he is alert.

leppie
+4  A: 

Not specifically C#/.Net, but one question we've used is to design a board game, such as Monopoly or similar. That, in my view, is more interesting since it involves both understanding OO (how to represent the different streets, houses, cards etc), and could also include delegates and events (for example, how is one notified of a player standing on my street). Could be made as simple or advanced as you want to.

Also, the best result we got was when we left the applicant alone for a while (say 30 minutes) and then had a debrief going through the answer. I usually didn't care about what they had written, but more that they could justify their choices.

Mats Fredriksson
30 minutes is too little to spend on design. This will just lead to cowboy coding.
leppie
It's a job interview to get a high level OO design.
JeeBee
We didn't expect anyone to write full code for anything, just either UML or class definitions. So this isn't perhaps the best example of a programming question, but I think it is a good question for a programmer.
Mats Fredriksson
+11  A: 

We also give a test to candidates.

Although it's important to monitor progress, I don't think it's fair for the test to be set to a tight or rigid time limit. In interview conditions you need to give people time to relax, burn off the adrenaline and clear their head. I've seen good candidates fluff things for an hour before getting their head straight and showing their true talents.

Pop in every 30-45 minutes to provide some guidance and comfort. It will be clear if they simply don't have a clue and things need to be bought to a close. Beyond that, cut them a lot of slack - it's the only way they'll relax.

mancaus
+14  A: 

In the past I've given candidates for both Java and C# positions a broken and unfinished piece of code along with a spec. The basic question is "take a text file which consists of lines of numbers, and produce another text file which has one line of output for each line of input, but the output line is the average, min and max numbers in the input line". There are additional things like blank lines and comment lines.

What I look for:

  • Reading the spec and pointing out deficiencies. (What kinds of input numbers? What range? What should the output format be for the average? What should we do on parse failure? What encoding is the file in? What culture is it in?)
  • Writing unit tests (I usually provide an empty unit tests directory as a hint that I'd like to see some)
  • Refactoring for testability (don't deal with files, deal with readers/writers)
  • Ability to spot defects in existing code (failure to close resources, bad min/max detection etc)
  • Ability to write the actual code to implement the solution
  • Ability to talk about what they're doing
Jon Skeet
+34  A: 

I prefer to ask "Let's have a look at your hobby projects", instead of telling him to write one.

This shows me:

  • If the developer is really self-developing person and likes to code on his own
  • How does he develop on his own without any pressure (style, quality, tests, architecture etc)
  • If his projects are open-source (even if they are small) and used - that's even better. It shows open-mindness, ability to self-organize and contribute (to the community or team) and learn from the feedback.
Rinat Abdullin
IF only employers would take that extra step...
leppie
If the employer is desparately looking for good devs, he will ask the question. Although it is hard to find an unemployed OSS developer))
Rinat Abdullin
Interesting idea, Rinat. I wonder what the percentage of developers is that writes code outside of "work". Sounds like a question to pose.
itsmatt
Great idea! Done)http://stackoverflow.com/questions/157319/do-you-have-a-hobby-development-project
Rinat Abdullin
Great - except that I have other responsibilities (wife and children) when not working... theory is good, practice may be prejudicial.
Murph
@Murph - I have a wife and children as well, but I love to code so much that I get up a few hours early or stay up later to work on personal projects. I can't get enough...
kirk.burleson
@kirk.burleson I'm not suggesting that families necessarily preclude hobby projects - more that in a litiguous age one would be putting the business into a potentially difficult position.
Murph
Coding outside of work doesn't always mean you're going to be a better employee. I know that 8 hours a day is enough for me... Otherwise I'd be using a computer pretty much all day. On the contrary, NOT coding at home would suggest to me that you have other things in your life such as sports, friends - it might indicate that you maintain a good work-life balance. At my workplace, we are encouraged to work on an individual or quality improvement project as well as whatever project we're on, asking about that might be more useful. Sorry for long comment....
rmx
A: 

I've done a few tests recently. One was to develop a Windows.Forms application that allowed Create/Update to a database (that also had to be created). They were looking for a developer that knew how to interact with a database, and also knew basic database design principles (normalised database design, stored procs, etc.). I was allowed 30 minutes for this, and there were also a few bonus points (allow delete if you have time, etc.).

Another test I've seen (although not a 30 minute test) has been rather simple in nature: copy a file structure from here to there, where here and there is dynamic. Also allow for optional recursion in copying. What they were looking for here was a design principle (if any), and the ability to solve problems. The applicant is given this at the end of the first interview, and is given a day or 3 to complete and submit completed (working) code.

Both approaches have their ups and downs, and I have no preference as a developer on the receiving end.

Raithlin
+3  A: 

I think there is no one answer here, insofar as it is domain specific, and you will want very different skills from say a front end GUI type, a comms guy or gal, or a algorithms person. I work in the geospatial area and the task I usually give is as follows,

Given an ASCII file of X,Y,Z coordinates

1) Read them into an array

2) Plot them on screen to fit in a given window

3) Calculate the shortest distance of all possible distances between the ponts an display on screen.

4) Write the two points and disance to an output file

I give one hour for the above and find many people don't finish. The problem (3) provides scope for the good programmer to discern themself from the average programmer. It also generalises reasonably well into

Get some information from your preferred source

Manipulate it

Report on it

Store your results

Shane MacLaughlin
I'm not really into C#, but is that even possible within 30 minutes?
Robert Gould
"I give one hour for the above [...]" - I believe 30 minutes is to lean for this (particularly no. 3) but in one hour it's absolutely viable.
Anheledir
This is a waste of time, however long it will take. There are too many assumptions you make about the developer. If he gets stuck at 1 point he is screwed.
leppie
The dev would only be sitting down to this test if they had already claimed they had these skills in the interview. A good dev, who didn't know part 1 might even press F1 and copy it from the online help ;) Resourceful developers overcome all sorts of obstacles.
Shane MacLaughlin
You're asking people to solve the traveling salesman problem in an hour? Really?
Derrick Turk
Nope, travelling salesman is the shortest route between two points on a graph. I'm simply looking for the shortest distance between any two discrete points in a set of points. Brute force, comparing the distance between every combination of two points is O(n^2), and can be done in a few ines of code. Smarter methods will be much faster but a more complex.
Shane MacLaughlin
Actually, if the salesman in question had a helicopter rather than a car, i guess this is the travelling saleman problem ;)
Shane MacLaughlin
+8  A: 

What I've found good is to register at Topcoder and then try doing some of the easy questions from the sample rooms. If you can do it yourself easily, then try giving it as a programming exercise during the interview.

Surprisingly, this weeded out a lot of our candidates. And if you talk to them about it afterwards, you can get an idea whether it was because of nerves, or that they just are clueless when it comes to programming.

Here is an example of an actual problem:

Problem Statement

You are climbing a staircase. The staircase consists of some number of flights of stairs separated by landings. A flight is a continuous series of stairs from one landing to another. You are a reasonably tall athletic person, so you can climb a certain number of stairs in one stride. However, after each flight, there is a landing which you cannot skip because you need to turn around for the next flight (which continues in the opposite direction).

You will be given the number of stairs in each flight in a Integer() flights. Element 0 of flights represents the number of stairs in the first flight, element 1 is the number of stairs in the second flight, etc. You will also be given an Integer stairsPerStride, which is how many continuous stairs you climb in each stride. If it takes two strides to turn around at a landing, return the number of strides to get to the top of the staircase. You do not need to turn at the top of the staircase.

Definition Class: StairClimb
Method: stridesTaken
Parameters: Integer(), Integer
Returns: Integer
Method signature: Public Function stridesTaken(flights() As Integer, stairsPerStride As Integer) As Integer (be sure your method is public)

Constraints flights has between 1 and 50 elements, inclusive.
Each element of flights is between 5 and 30, inclusive. stairsPerStride is between 2 and 5, inclusive.

Examples

{15}
2

Returns: 8
A simple staircase with 15 steps. In 7 strides, you've climbed 14 steps. However, you still have one step left, so you must use an additional stride to get to the top.

{15,15}
2

Returns: 18
This time, there are two flights with a landing in between. 8 strides to get to the first landing, 2 strides to turn around, and 8 more strides to get to the top makes 8+2+8=18 strides.

{5,11,9,13,8,30,14}
3

Returns: 44

RickL
+6  A: 

Here is one that was given to me in a recent interview. It was a java question, but can easily be used for any exam.

Write a Java method that converts a Roman Numeral to an Integer i.e. Integer convertRomanNumeralToInt(String aRomanNumeral)

based on the following rule

A numeral is a symbol used to represent a number. (Our digits 0-9 are often called Arabic numerals.) Each letter used in Roman numerals stands for a different number:

RN   Number
I   1
V   5
X   10
L   50
C   100
D   500
M   1000

A string of letters means that their values should be added together.

For example, XXX = 10 + 10 + 10 = 30, and LXI = 50 + 10 + 1 = 61. If a smaller value is placed before a larger one, we subtract instead of adding. For instance, IV = 5 - 1 = 4. You can use these rules to write a number in Roman numerals. Convert one digit at a time. Let's try 982: 982 = 900 + 80 + 2 = CM + LXXX + II = CMLXXXII.

A smart developer (who thinks out of the box and does not only write code but also thinks about the process and functionality) will tell you that the specification is incorrect. For example: XIX does not mean 10+1+10 but 10 + (10 - 1). If you would present me that example I would ask you to come up with a better specification which is more "realistic" (and hope you will find me a very wise and intelligent developer and will offer me the job) ;)
Gertjan
@Gertjan: A smart developer has reading comprehension: "If a smaller value is placed before a larger one, we subtract instead of adding. "
SnOrfus
I solved this programming puzzle recently elegantly but I still didn't get the offer(they were other interviews but this one went pretty good)
satyajit
+5  A: 

Above are a lot of good questions which will tease out the technical/logical skills and you should definitely use them. But if you want to get inside the persons comprehension and general awareness I suggest asking them to draw a picture of the architecture of the product/project they are currently working on.

In my experience a really good developer will leap up to the white board and start drawing and will encompass lots of things that they have no direct involvement with. A really bad one will not have a clue. And there is a lot in between.

What I think this demonstrates is their ability to grasp the bigger picture of the environment in which they work and a sense of their contribution to the larger architecture they are working within. It also shows clearly their communication skills, both written (drawn) and verbal.

If a developer is ever going to grow further than being able to solve complex puzzles they need to have their heads up.

Simon
Good one, but I'd be very careful about asking this question though. The candidate might be under NDA and depending on the circumstances the practise may lead to the company taken to court.
Totophil
+2  A: 

Before asking for the best question, ask yourself what are you want to test.
No single 30 minutes test will give you understanding real potential/problem of the candidate.
You need to decide what are you testing: ability to learn, knowledge, capability to work under pressure etc...
Try do define what is the expertize of the best person you want to hire, not the one you will be willing to compromise - the best one. See how to test each of this expertize and build your tests accordingly. I strongly suggest to have few tests and only one. Building a score sheet is helpful as well otherwise it's really hard to compare candidates.

We are running 3 stages interviews.The stages are not time limited, we decide on the fly if there is a point to go further.

  1. First test is just to wipe out the completely not capable (on the paper with no R&D resources involved except final checking) i.e very simple question may with some simple twist.
  2. Second one a little bit more advanced and check for programming skills we are testing for understanding of pointers. Link list implementation is a best way to see if somebody understand pointers. (we are
  3. The last one and the most important test for ability to learn - we ask question that we hope the candidate don't know the answer and by giving tips leading to solution.
Ilya
+1  A: 

You should be giving them a series of problems that gets progressively harder. Starting out extremely easy serves two purposes.

1) It quickly separates out the people who can't code.

2) It makes the ones who can code comfortable and gets them ready for the harder questions.

I can't really give you any sample questions because I don't know what you're testing for. If you're just testing to see if someone knows language syntax you should be able to find that out very quickly. If you want to test problem solving ability, give candidates a few of the early problems from Project Euler.

Bill the Lizard
Project Euler is a lot of fun to figure out, but there's not much object/class design problems in them as much as they're algorithmic in nature. In essence, a math grad with the slightest programming experience will do well, but still be a poor software developer.
SnOrfus
+1  A: 

Lots of interview questions popping up today.

Personally I don't think picking a complete program is a great idea for an interview question. Why, because it's too static. Interviews should be dynamic because lets face it our job is dynamic. You don't ask a developer to sit in a corner for a week, write a program and grade it at the end. It's an iterative process where challanges pop up and discussion is rampant.

I prefer to start off with a simple question that can be made harder in many different ways. Based on the performance of the interviewee on the initial question I add new constraints, input or complexity requirements and see where they go with it.

Unfortunately all of my interviews tend to be in C++ right now so I can't give a great C# example.

JaredPar
A: 

First, pick a problem you understand very well. Otherwise, it becomes hard to judge the candidate. Second, pick a problem simple enough that almost any good programmer can solve it, but hard enough that it will expose a weak programmer's deficiencies. In my experience, this isn't as hard as it sounds.

For example, ask them to implement the Array.Sort method (without of course calling the real Array.Sort). Poor candidates won't get anywhere. Medium ones should at least get a bubble sort working. Good candidates will get a solution working as well as be able to discuss things like the performance of their algorithm, the performance of an "optimal" algorithm, and how they think the real Array.Sort method might be written.

C. Dragon 76
A: 

I could see going in at a high level of build a prototype of a web form that took in a number, and 2 strings and stored them along with a datetime in a database table. This may sound overly simple but the idea is to drive out the requirements by asking questions and having a discussion which could really happen if someone were to say, "We'd like to store answers from these marketing questions so we could have statistics on blah blah blah" which I have done and seen and speed and quality are interesting to see how this is handled.

The idea here being that there is enough vagueness that the 30 minutes is spent working out what it is to do that having a completely done prototype at the end isn't likely, but then the idea is to see how do you build unit tests, how do you handle when you'd want to check in the code, what documentation would you give for this little application?

This could be a web form, winform or console application I'd think.

JB King
A: 

Start with the familiar "What websites do you visit every day" question to put them at ease. When they get to an interesting one, ask them how they'd go about building it on the whiteboard, and see what they choose to focus on in their design. Ask them questions in areas not related to the obvious requirements like scalability, transactionality, and security. If you like what you see, ask them to make a prototype of a small section.

MrGumbe
A: 

what codds wallop most of these test questions are.

most of the above dont test the candidates heuristc knowledge and experience let alone their programming aptitude or ability to source using reference materials and online sources which is what most programmers do in thr real world during a typical days work.

add to that most good progees are lazy, once they code they reuse and often have to look up what theyve done if needed to re-write and/or modify it.

what practical user is asking anyone to code from a specification for a flight of stairs -

show me a web site that this applys to?

its egg heads trying to be cleaver and out smart the candidates and probably rejecting good grounded developers

what about the basics: Accessibility Validation of markup Project life cycle Proficiency using visual studio and other daily routine tools Coding standards technical documentation ability communication skills team skills and many more .... grrr

mark
-1: Most of what you describe are skills or processes that are easily taught to intelligent people. The point is to find intelligent people: it's a bonus if they know these things already.
SnOrfus
+1  A: 

I've been using this one for a while. The smartest guys complete it within 30 mins, the others, well, most can't finish it, or have something half working.

This is a test for the low level coder though, as opposed to a web developer. It's in C++ and no libraries other than the standard MS Visual C++ stuff can be used.

The application reads a bitmap file from disk, performs some processing on the image data to make some basic modifications and save the image back to disk. The reading of the bitmap is implemented for you, the saving and image processing must be implemented.

This is the basic flow of the program required:

  1. Read a bitmap from file
  2. Invert the colours in the bitmap
  3. Increase the brightness of the image by 50%
  4. Save the bitmap to a new file

You have maximum 1 hour to complete the test. Concentrate on having a working application within the hour.

The only problem I've had is that it's filtered down right to the upper echelons of programmers. They generally end up with 2 bazillion offers and taking a role at Blizzard.

Must ... make ... company ... more ... attractive ... to ... work ... for!!

badbod99
Ah crap, I completed this in 12 minutes; does this mean I'm even smarter than every folk at Blizzard? ;-)
Jan Jongboom
I did of course forget to mention this is a C++ test with no other libraries. Still 12 minutes? Want a job ;-)
badbod99