Sep 29, 2011 17:28
So, I just did a Java test as part of a job application (or rather an application for a contract). Now this was one of the best tests I've been given. Gone are the "Do you remember this esoteric bit of the Java language which is so obscure that no one uses it?" and gone are the "Please recite a list of things that you could look up in a book?" and gone are the "tell me what the parameters of this method call are, which your IDE could probably tell you in seconds anyway".
The test was just "write a class which does XYZ. Tell us all the assumptions and design decisions you made. And tell us what sort of tests you might write". That last bit was helpful as I thought we might need to actually write loads of tests - but describing them is less work :-)
The code itself was a bit of a pain. It revolved around messing around with int arrays - which is a bit buggered in Java. There are loads of libraries for dealing with Collections of objects - and even ways of turning arrays into collections. But arrays of primitive types like int mean that you can't do the same sort of thing that you might do with Arrays of Integers.
So what is the solution? You could either treat it almost like a C problem, and leave things in the int arrays, or convert them to List and process them using Java's Collections libraries. I suspect that they wanted the former - I chose the latter. Seriously I want maintainable code more than I want blindingly efficient code. Yeah - I used more memory than necessary - but at least I said that.
Did I care about making it threadsafe? No - but I said it wasn't threadsafe, and nothing in the requirements said it needed to be.
The test was supposed to take one to two hours, and I did it in one hour. I could have spent another couple of hours writing tests, running tests, improving documentation... etc etc etc... but at some point you just have to put your "pen" down and hand it in.
werk,
java