Monday 17 August 2009

Testing time

As part of my job hunting I had to take an online Java test which is meant to adapt to the answers you give and adjust the difficulty accordingly. Since I've been in permanent employment for the past four and a half years and before that not really having to do any serious job hunting, it's been a while since I've done anything like this.

So, how did I do? Well, I don't get to find out yet, the results are sent only to the company who wanted me to take the test. I did remember some of the questions and so I've checked my thoughts on these and I did catch at least one or two of the sneaky tricks they had, though equally there are a few I think they tripped me up on.

One of the big features of these tests is code that no competent person would right; it's legal according to the language specification (or at least parts of it are) but it would immediately get thrown out by even the most cursory peer review. This is why I always valued working as a trainer or mentoring, essentially those with less experience generally do 'think the unthinkable' and ask questions that you just never dreamed of!

Anyway, just have to wait and see how I did and hope it was enough.

Aside: I was looking into Java generics, trying to understand how it worked from the JCP book I have. The book spent pages and pages with examples and comments intended to put the reader at their ease by admitting that this was all a little confusing and didn't really work how you would expect.

Too be honest this rambling list of the differences, exceptions and important notes concerning rules you MUST remember for the exam was confusing me and I really just wanted to know how it all worked, how did all this functionality get represented at a low-level. So I ran javad and decompiled java.util.List to see how the magic worked.

What I discovered was that all the generics functionality is simply a compiler 'trick' and there is no under-lying implementation. The information that pertains to the generics syntax is stored in attributes which are an extensible feature of the classfile format. This article gives a pretty good description of the mechanism, which is admittedly quite neat.

Now why couldn't the book have explained all this? Armed with this knowledge all the complicated rules and exceptions make perfect sense! Why burden the reader with a multitude of disparate facts when knowing the how and why of something makes it so much clearer?!

Erm, rant over I think.

No comments: