http://qs1969.pair.com?node_id=440978

A couple years ago I was looking for a job, and several of the interviewers asked for code samples. I was happy to hand over some rather trivial or academic things I had banged out in my spare time which I felt illustrated my skill level and good code-writing habits. One interviewer asked if I had anything more substantial to show him; something that was more "real-world" than academic. Unfortunately, all the large, real-world stuff I had worked on until that point was proprietary software for my previous employer, and as I no longer worked there, I didn't have access to it anymore. I explained the gist of the projects I worked on, what they did, how they were designed, and so on, but he was not satisfied. I explained that the projects were proprietary, and even if I still had the actual code, I couldn't give it to him.

He explained that, "for future reference" it was "expected" of programmers to keep real-world samples of their code from proprietary jobs, and that he had stuff he had worked on for a number of large companies. That certainly did not sit well with me, but I was looking for work, and even went so far as to ask my old boss if he could send me some of the stuff I had worked on. (In this case, a base class that would be pretty useless without the real guts in the derived classes.) Of course my old boss said no as expected.

I've only had three full-time jobs in my carreer thus far (one for three years, one for three months, and my current one.) But I've been on at least 25 interviews during that time. Several of them asked for code samples, but only that one asked to see proprietary code. After thinking about that experience for a while, I realized that he was probably just incompetent at best, a jerk at worst, except for what he mentioned about it being "expected" for programmers to keep stuff they've worked on. That still piques my curiosity. So,

  1. What do you provide when interviewers ask for code samples? Do you try to tailor your samples to the specific requirements of the job?
  2. Has an interviewer ever asked you for proprietary code? What was your response?
  3. Do you keep code you have worked on in the past, even if it is just for reference and you have no intention of showing it to anyone?
  4. If so, do you think this is a normal or common practice among programmers?

I didn't get that job, of course, and my current employer didn't ask for any code samples at all. (And it has turned out to be a great job.) So I'm interested in your experiences.