ACCU Home page ACCU Conference Page
Search Contact us ACCU at Flickr ACCU at GitHib ACCU at Google+ ACCU at Facebook ACCU at Linked-in ACCU at Twitter Skip Navigation

pinAfterwood

Overload Journal #143 - February 2018 + Process Topics   Author: Chris Oldwood
Can you code on paper in an interview? Chris Oldwood recounts his attempts to write a calendar.

The interviewer slid a pencil and a sheet of A4 paper over in my direction and said “I’d like you to write a little bit of code to print a calendar.” I thought to myself “that doesn’t seem too hard”.

This wasn’t the very start of the interview, there were a few pleasantries exchanged before cutting to the chase. In that opening introduction, I quickly learned that my interviewer did not work in my department or even my programming language of choice. His personal preference was for Java but given that this was a brand new team with only a project manager who hadn’t written a line of code in years, he was drafted in from another team to fill the void. I let out a disguised sigh of relief as I realised I wasn’t going to get quizzed about obscure C++ trivia.

I quickly doodled a picture of a calendar in the corner of the paper just to clarify what kind of thing he might be after, and he muttered in agreement.

I then traced over the doodle again, which is odd, because I never doodle in my log book. All of a sudden I became aware of the situation I was in – a job interview. I tried to focus, thinking to myself “I just need to write a function to draw a calendar; that should be pretty easy. He doesn’t even know C++ so it’s not a language test; he just wants to see me write some simple code.”

The room began to feel small. Being a typical corporate meeting room the décor was noticeably drab, this wasn’t the place you’d ever consider bringing a customer; so it can be palmed off onto a bunch of IT people. The lack of a whiteboard also suggested this was no place for collaboration, which was odd, because so much of what is wrong in software development is down to a distinct lack of this very exercise. Once again my mind wandered from the task at hand as I begin to consider whether this omen was foreboding.

More time passed and I’ve still written no code. This can’t be looking too promising now so I make a light hearted attempt to cover my tracks by suggesting it’s really weird writing code with a pen and pencil. Which of course it is.

I break the impasse by just writing a boilerplate function signature void printCalender() and then add a couple of braces. I immediately realise adding the closing brace was stupid, how can you insert code on a piece of paper? Once more I make light heart of the situation by commenting on how used to a text editor I’ve become. He agrees. I ask him to pass the ‘delete key’, by pointing at the rubber just out of reach, and he obliges.

I need to get a grip. I tell myself to stop making small-talk and get on with the task at hand.

Finally I seem to be able to concentrate. My sketch of the calendar suggests a 2D structure so I start writing a pair of loops, one from one to seven for the days of the week and another for up to 5 weeks. As I mentally walk through the output I realise it’s just a stream and so I only need one loop and some modulo arithmetic. I apply the ‘delete key’ liberally once again and focus on the single loop approach. Only now I can’t see what it looks like as my mind has raced ahead to realising I have no idea what date type I’m going to use, such as for working out which day of the week the 1st of the month is, or how many days the month has, or if it’s a leap year, or …

My vacant expression and another period of extended inactivity has come to the interviewer’s notice and once more I’m on the back foot. This time I bemoan that lack of a decent date/time class in C++ and waffle on about Boost, time_t and OLE date/times. He sympathises but, probably unintentionally, only makes things worse by pointing out how much you get out of the box in Java. This time I joke about the lack of access to Stack Overflow, or the internet in general for assistance.

It’s now dawned on me that I didn’t start with a failing test! Test-first development is still fairly new to me at this point due to being knee deep in legacy code for years, but I want him to know that it’s something I would normally do. I fire off a throwaway comment and try to gauge his response but fail to detect if TDD is his natural way of life or not and therefore have to let it go.

I realise I’ve just blamed the test process, again! Where is the Singularity to swallow me up and put an end to this nightmare...?

Time’s up! The page contains some faint scribbles and I try my best to elucidate my thought process, in particular how my gut says it’s just a simple loop and some modulo arithmetic and I apologise for failing to get anything remotely readable down on paper in time.

He thanks me for my time and slips me a small piece of paper with his email address on it and, almost as a passing gesture suggests I could always contact him later with the answer. I know he’s just being polite though.

I trudge home, annoyed at how badly I’ve done. Similarly, I lament to the agent about my inability to write such a simple piece of code. Naturally he’s supportive but it makes little difference to my self-deprecating mood.

The evening slowly passes and my thoughts turn to the piece of paper with his email address on it. I start to ponder “was it a genuine lifeline, or just an act of consolation? Is he merely offering me closure or a second chance to redeem myself?”

I fire up my computer and start bashing out some code. I decide I’m not just going to answer the question, but I’m also going to do it both ways –the two loop approach I fumbled towards, but also the single loop, streaming approach I knew was possible. And I was going to do both using a test-first approach for good measure!

At about 10 pm I zipped up both sets of code and mailed them off. I was happy that even if he didn’t read the email I knew that I could have done it given a normal working environment.

The following morning I took the kids to school and just got on with my life knowing there were other jobs out there and that I’d have my day soon enough. Then the phone rang, it was the agent, “I don’t know what you did but they want to see you again right away!”

Overload Journal #143 - February 2018 + Process Topics