Sunday, May 14, 2006

How would you test this code?

This past weekend I went through a hellish interview with the home office PM for one of the positions I am interviewing for. Making the interview harder than usual was the fact that it was held early in the morning to synchronize our schedules. Also, it was a phone interview and that brought with it all the bad reception problems that that brings along.

Groggy and unable to hear half the interview, I plowed through the best I could. Unfortunately, I don't think I made the best impression I could.

One question I got especially hung up on had to do with testing of code. First, I was asked to code up a fairly simple set of functions that translated some data from one format to another. Then I was grilled for 15 minutes on the intricacies of the C function call conventions. He asked me why the incremented parameter in the subfunction was not also updating the passed variable in the calling function and I couldn't wrap my head around what he was asking. Pass by value, pass by value, pass by value. It's all I could think of to answer. After 15 minutes of trying to dig deeper into the question, I finally figured out that he was trying to get me to explain how pass by value works and how it uses the callstack, etc. That was a big minus, I think.

After answering the question to his satisfaction (as satisfied he could be with an answer that took 15 minutes to cajole out of me), he asked me how I would test this code. I don't think I have a good answer for that.

Obviously there are some general criteria for any testing. Internal consistency (parameters OK), external consistency (return values OK), performance criteria, thread safety, correct processing, correct error handling, etc. However, none of these came to mind due to the frazzled state of mind. What did come to mind were specific test cases that exercised the function as much as necessary, but I don't think that's what he was looking for.

To be frank, I believe myself to be undertrained in this general area. I am looking to improve my code testing processes, and am wondering where to begin looking. Kaner, et al. is where most of my testing knowledge comes from, but that generally approaches the testing process from a tester's point of view rather than a programmer's point of view.

I am aware of methodologies such as Agile, but I am looking for something more basic that can give me a good idea about what code testing is and the useful techniques for approaching the problem. The ultimate goal isn't just to pass some interview, but rather to improve my efficiency as a programmer.

Any ideas where to start looking?

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home