Biz & IT —

Can and should you ask for a code sample during a company interview?

Is it presumptuous? Or does it make you look professional?

Can and should you ask for a code sample during a company interview?
Stack Exchange
This Q&A is part of a weekly series of posts highlighting common questions encountered by technophiles and answered by users at Stack Exchange, a free, community-powered network of 80+ Q&A sites.

Simon asks:

Asking a job seeker to show some code is a fairly common practice for a software company. However, would it be acceptable for the candidate to ask the interviewer to show him a small piece of code that he thinks is well written?

Related: "What to ask about a company before deciding to work there?"

Answer: Always ask (43 votes)

tdammers replies:

I always ask to see some code, for several reasons:

  • I want to know what I'm getting into. Of course no software firm is perfect, and I don't expect everyone to pump out marvels of elegance all the time (because neither do I), but if I ask for a company's very best code, and all they can show me is a sub-par spaghetti mess, I know I'm in for a miserable time, unwrapping hairballs and fighting the technical debt to get anything done. Looking at the best code a company can show establishes an upper limit of what kind of quality is possible there; even if it's unlikely that all their code looks like that, you still know it is something they strive for.
  • Looking at code samples tells me a lot about a company's coding culture. Do they use documentation comments? Do they lean towards an Object-Oriented style, do they have Functional Programming tendencies? Are they conservative or progressive? Do they value consistent naming, proper formatting and indentation, and neat code in general? Is the code easy to follow? How do they structure their projects? How do they approach the important things—automated testing, error handling, etc.? How defensive is their coding style?
  • Seeing their existing code will allow you to judge whether you can live up to their standards.
  • The fact that a company is willing to share code samples alone is a good sign in principle. It means that they offer me, the applicant, some trust, since their codebase is one of their most valuable assets. It also means that they are not ashamed of their code, that they are confident that showing me the code will help interest me in working with them.
  • If they won't show you any code samples, then that doesn't have to be a red flag, but it is wise to both ask why they won't share (quite likely, they simply can't for legal reasons), as well as explain why you want to see some. I don't think showing interest in their code is going to be seen as a negative sign, as long as you ask politely and positively.

Companies that do agree to show you code are unlikely to just send a tarball of source files containing the latest version of their entire codebase, for obvious reason. If they show you any code, they will do so in the form of a little demonstration, which is great: it means I get to talk to one of my potential peers; it allows me to ask more questions about their coding culture, processes, and codebase; and ideally, it will help start a professional discussion in which I can both demonstrate skills and knowledge and learn more about the work environment. It also means that I get to look at the tools they use, which is also quite insightful—for example, if the project they show me relies heavily on a particular IDE, this means that everyone uses that, which can be good or bad. And finally, talking through a bit of code gives a good impression how well future professional communication might go.

Answer: Ask, But… (7 Votes)

Caleb replies:

You can ask whatever you want, but:

  • You probably won't get it.
  • If you do get it, it won't tell you anything useful. If 10 percent of their code is beautiful and the rest is spaghetti, you'll still be dealing mostly with spaghetti.
  • You'll seem like a smarty pants. That's not a big help if you ultimately decide you'd like to work there.
  • It's a waste of precious interview time.
  • There are better ways to find out what you want to know. Ask questions like:
    • What are the most important indicators of code quality?
    • Will I be mostly maintaining existing code or writing new code?
    • Can you explain briefly how your system works?
    • Do you have a coding standards document, and does everybody follow it?

Related: "How can I tell in an interview if a programmer is passionate about programming?"

Answer: It Depends (3 Votes)

Patkos Csaba replies:

Well, it depends. I always liked to know where I am going to work.

I see a job interview as bidirectional. The company finds out about you and you find out about the company. Asking for code may be a little bit much, but asking development related questions should be OK.

For example, I would not accept a job where the company doesn't use agile techniques or TDD or doesn't plan to embrace and encourage such practices. I also appreciate when a company is proud of their product and their code—when it seems the interviewer is waiting for you to ask to see it so he has an excuse to explain all the cool stuff they do.

Think you know if it's OK to ask for code samples during an interview? Disagree with the opinions expressed above? Bring your expertise to the question at Stack Exchange, a network of 80+ sites where you can trade expert knowledge on topics like web apps, cycling, patents, and (almost) everything in between.

Channel Ars Technica