I had to take a technical test for legal skills recently. And that got me talking with a client of mine that uses technical tests to assess coders prior to hiring them.
This post is to talk about the test he uses, whether you think it is good and whether you would like to have a go. Here is the abstract of the test (it can be used for any language).
Premise:
to build a one-sided game of battleships
Rules:
the grid is 10 x 10. Rows identified with A-J. Columns with 1-10.
five ships should be placed on the grid. one ship should occupy 5 contiguous squares, the other four should occupy four contiguous squares.
No ship may intersect another ship. They may abut one another.
ships don't go round corners (i.e. they cannot be bent at an angle)
the player selects a square and is told whether the selection is a miss, a hit, a sinking or game over.
Functional Requirements:
the layout of the ships on the grid must be random (or as random as the chosen language allows)
the coder should code for a console (web or cli but the output should be console-like)
on the grid:
X designates a hit
- designates a miss
. designates an unchosen square
the coder must implement a cheat functionality to display the whole grid with ships on it. The cheat should be engaged by typing 'show' and reversed by typing 'hide'.
squares are chosen by the player entering the row,col coordinates.
Non Functional Requirements
The code should be well commented in accordance with documentor standards
It is not sufficient just to code the solution . The code must be elegant/beautiful and the best you can do.
The code should make use of OOP where practical and some form of layer abstraction (MVC or otherwise) so as to separate logic from display.
There is no particular time limit but seemingly most complete it within 4-8 hours
I did this one night and then tweaked it a few days later to allow for diagonal placement of the ships too (there is no statement either way as to whether diagonals are allowed - in my childhood when we played this game on paper diagonals were allowed, in the electronic version they are not).
I did not properly read the spec so I coded for a CLI and a web solution. my timings were thus:
30 mins: basic layer of functionality (class structure, pseudo-random grid layout)
30 mins: tidying up cli output
60 mins: ajaxed web interface
20 mins: web-console interface
30 mins: refactoring to provide feedback messages on square choice
30 mins: refactoring again because I got the letters along the top rather than down the side of the grid (annoying)
10 mins: refactoring to allow for diagonal ship placement
note that I did not comment my code as I was not doing this for any purpose other than intellectual satisfaction. I imagine that properly commenting the code would have added at least half an hour over the full period, even though I would have done it as I went. Annoyingly my IDE has stopped auto-commenting after a recent upgrade.
if anyone is unclear as to what batteleships is click here
My solutions are published [link battleships.no3.co.uk]here[/url] to show a working example of a permitted end-product. The code works fine for CLI too of course.
I think my times were less than the average simply because I have more experience. With experience you get to a decent structure more quickly. If I had read the spec properly rather than drinking wine, I would not have needed to refactor twice.
The same is true in law - I am no better a lawyer innately than someone half my age. But I will be quicker and more likely to be correct first time because of more experience.
So back to the questions:
1. is this a fair way to measure coding skills? If not, how would you test?
2. would it be better to place a time limit on it? ie. does a client want not only good output but good output under pressure?
3. how would you improve this test (I introduced some db storage to showcase a basic ability to code sql queries - i think this is a big weakness in php coders that I review professionally - their queries, on average, are hastily put together and show little appreciation for optimisation)?
feel free to play and publish your solutions here!
This post is to talk about the test he uses, whether you think it is good and whether you would like to have a go. Here is the abstract of the test (it can be used for any language).
Premise:
to build a one-sided game of battleships
Rules:
the grid is 10 x 10. Rows identified with A-J. Columns with 1-10.
five ships should be placed on the grid. one ship should occupy 5 contiguous squares, the other four should occupy four contiguous squares.
No ship may intersect another ship. They may abut one another.
ships don't go round corners (i.e. they cannot be bent at an angle)
the player selects a square and is told whether the selection is a miss, a hit, a sinking or game over.
Functional Requirements:
the layout of the ships on the grid must be random (or as random as the chosen language allows)
the coder should code for a console (web or cli but the output should be console-like)
on the grid:
X designates a hit
- designates a miss
. designates an unchosen square
the coder must implement a cheat functionality to display the whole grid with ships on it. The cheat should be engaged by typing 'show' and reversed by typing 'hide'.
squares are chosen by the player entering the row,col coordinates.
Non Functional Requirements
The code should be well commented in accordance with documentor standards
It is not sufficient just to code the solution . The code must be elegant/beautiful and the best you can do.
The code should make use of OOP where practical and some form of layer abstraction (MVC or otherwise) so as to separate logic from display.
There is no particular time limit but seemingly most complete it within 4-8 hours
I did this one night and then tweaked it a few days later to allow for diagonal placement of the ships too (there is no statement either way as to whether diagonals are allowed - in my childhood when we played this game on paper diagonals were allowed, in the electronic version they are not).
I did not properly read the spec so I coded for a CLI and a web solution. my timings were thus:
30 mins: basic layer of functionality (class structure, pseudo-random grid layout)
30 mins: tidying up cli output
60 mins: ajaxed web interface
20 mins: web-console interface
30 mins: refactoring to provide feedback messages on square choice
30 mins: refactoring again because I got the letters along the top rather than down the side of the grid (annoying)
10 mins: refactoring to allow for diagonal ship placement
note that I did not comment my code as I was not doing this for any purpose other than intellectual satisfaction. I imagine that properly commenting the code would have added at least half an hour over the full period, even though I would have done it as I went. Annoyingly my IDE has stopped auto-commenting after a recent upgrade.
if anyone is unclear as to what batteleships is click here
My solutions are published [link battleships.no3.co.uk]here[/url] to show a working example of a permitted end-product. The code works fine for CLI too of course.
I think my times were less than the average simply because I have more experience. With experience you get to a decent structure more quickly. If I had read the spec properly rather than drinking wine, I would not have needed to refactor twice.
The same is true in law - I am no better a lawyer innately than someone half my age. But I will be quicker and more likely to be correct first time because of more experience.
So back to the questions:
1. is this a fair way to measure coding skills? If not, how would you test?
2. would it be better to place a time limit on it? ie. does a client want not only good output but good output under pressure?
3. how would you improve this test (I introduced some db storage to showcase a basic ability to code sql queries - i think this is a big weakness in php coders that I review professionally - their queries, on average, are hastily put together and show little appreciation for optimisation)?
feel free to play and publish your solutions here!