Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
14  
I'd rather ask about coding standards, code reviews, etc. –  user16764 Aug 29 '12 at 16:38
5  
Does the company pass the "Joel test": joelonsoftware.com/articles/fog0000000043.html –  Loki Astari Aug 29 '12 at 16:52
2  
@LokiAstari the joel test does not directly concerns coding culture (only working environment). –  Simon Aug 29 '12 at 16:57
8  
@user16764 that is like asking theoretical questions to the candidate: it is good first step, but it does not really show you how he applies this knowledge. –  Simon Aug 29 '12 at 16:58
2  
programmers.stackexchange.com/questions/160922/… Similar to this question. –  Anonymous Aug 29 '12 at 17:14
show 2 more comments

8 Answers

up vote 70 down vote accepted

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.

And then there are some more side effects:

Companies, those that do agree to show you code, are unlikely to just send me a tarball of source files containing the latest version of their entire codebase, for obvious reason. If they show me 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.

share|improve this answer
10  
Awesome answer. –  Eric King Aug 29 '12 at 22:35
1  
If the potential employer shows you code that is clearly bad, remember it could be an opportunity to lead them to improve their code and processes. As the old saying goes "I can only screw up perfect but I can fix broken!". Also, remember code being shown to or by a candidate was probably subjected to much more rigour and review than other code. –  akton Aug 30 '12 at 7:42
    
@akton It is my attitude toward bad code. However it is useless when you are alone in your "fixing messy code" quest. Asking to see some good code could help to feel if your future team value things like SOLID –  Simon Aug 30 '12 at 12:08
1  
"I always ask to see some code" How after are you actually shown code though? Are you asking for them to prepare something beforehand or send you something afterwards? No matter which way you look at it, it seems impractical. –  Burhan Ali Sep 2 '12 at 14:20
1  
@BurhanAli: I just ask. Many refuse to show me any, and usually they give me good reasons, which is fine. Those who agree give me a supervised tour; I doubt anyone would mail me a complete set of sources to nose through, but clicking around the project in an IDE while I watch is often acceptable. –  tdammers Sep 2 '12 at 14:34
show 1 more comment

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?

I suppose that falls into the whole 'interviews are bidirectional' mantra, but I wouldn't expect to get any. Intellectual Property concerns are the most obvious issue after the fact that there's no computer in the interview room, and bringing you to one is kinda awkward.

Further, they're just going to cherry pick the best looking, least meaningful code they can. The best code isn't really a problem, the worst is. It's the same reason that getting code samples from candidates is next to useless.

share|improve this answer
10  
It is still useful to see if they can cherry pick good code to show you. The most frustrating part of dealing with bad code often is that no one recognizes it is bad and should be fixed. –  JGWeissman Aug 29 '12 at 17:57
5  
Also, the interviewer's idea of good code may not be your idea of good code. I would think it would be useful to find that out sooner rather than later. –  Eric King Aug 29 '12 at 18:04
1  
Sadly when I've tried to use the "interviews are bidirectional' approach most employers have acted annoyed. I've never yet been shown code. The other thing I've asked to see is a data model, but no luck there either. –  Antonio2011a Aug 30 '12 at 8:12
add comment

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?

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% 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?
share|improve this answer
    
Good point ! Sadly asking a question like "What are the most important indicators of code quality?", may be perceived as being a smarty pants as well. (From my perspective it is a reasonable question, but a lot of employers don't like to feel like they are being quizzed by a potential subordinate). –  Antonio2011a Aug 30 '12 at 8:16
2  
@Antonio2011a Should be fine if you ask right -- perhaps "what code quality metrics do you look for here?" just make it clear that you want to learn more about how they do things. You're learning about them, not administering a test. Could work even when asking for code: "Could I see what your code looks like?" rather than "I'd like a sample of what you consider good code." –  Caleb Aug 30 '12 at 12:21
add comment

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.

share|improve this answer
    
Agreed. I tryto delve into the tools they use? Do management pay for extra tools (components, utilities) that many places don't. Attitude to open source tools is always a good one too. –  Ozz Sep 4 '12 at 22:49
add comment

Haha, that's a funny question. I wouldn't be offended if somebody asked me for a code sample while they were interviewing, but I probably wouldn't show them any code, either, unless they had asked in advance and I had time to plan carefully.

I definitely understand the intent of asking such a question though. As a job-seeker, I have asked the Joel Test to an interviewer before. They didn't know what it was, but they were happy to answer.

In some places, asking those types of questions might improve your chances while it might hurt your chances elsewhere. The beauty of life is that if it improves your chances, then that's the kind of place you would want to work. If it hurts your chances, then you wouldn't have wanted that job anyway.

I see nothing to lose by asking politely and being able to explain why you want to see it.

share|improve this answer
    
"The beauty of life is that if it improves your chances, then that's the kind of place you would want to work." +1 –  Spidey Dec 3 '12 at 3:08
add comment

I have asked this question at my two interviews where they claimed they had senior devs migrating to asp.net mvc3 or 4 or when they said they want heavily commented code. I have rejected at both occassion due to lack of their knowlege on actual code standard. The only standard i found was if it works copy and paste it and it will work. I wont ask this question if i am doing a new project or have to write piece of code independent from others in the team. I will definitely see the code if i am being hired to fix an existing software or function and i wont say yes unless i know the answer. Assume you dont ask and they say can you please fix the datepicker to start from todays date. When you look at legacy code you see no jquery or jquery ui but a custom made date picker that has all dates stored in xml file and every night a cron job runs to update future months on it. That would start the headache as code to achieve this is less than the words in this example. If you are going to work on their code ask to see it. Not asking is like quoting for a job on belief that customer said its small. He might own 20 acre land and gardening on his 1 acre is small for him but gardner cant charge 50 quid just because all his small jobs start from 50.

share|improve this answer
add comment

I tend to work for companies where at least part of their work is open source, so it's trivial to find code samples. I figure out who works at the company, then figure out their online handles. Since people tend to use the same screen name, over and over, it's easy to find where they've committed code, whether they were on Github, Bitbucket, or somewhere else completely.

My current company has a ton of code hosted on Github, so it was easy to see what they work with, how big their code base is, and what seems to be no longer of interest.

I would never ask for a sample, simply because they're going to show you the best code they have. This is not the code you'll be working with. It's probably housed in a bell jar in a locked room. You'll be working with the messy code that many people have had to mess with.

share|improve this answer
add comment

This is awesome if you can get it. Sometimes it isn't possible without NDA-type agreements, but it is always good to try. To increase your odds, let your interviewers know you want this well in advance (a couple days) so they can have something in mind to show you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.