I recently was interviewed by a software company for a software development position. I was asked the following question: "what is your definition of clean code?". I answered the question with what I would really like about a code. However, it doesn't seem there is a correct answer to this question since this is very subjective. So:

1- Was this question an appropriate interview question?

2- Is this a common question? If so, what would a bad answer to it would look like?

  • 2
    If you wrote "I write clean code" (or something to that effect), they probably just wanted to know what you meant. I've never had this question appear during an interview (I'm not in HR or management/part of the interviewer processes - just an interviewee)
    – hd.
    Commented Jul 20, 2015 at 8:30
  • possible duplicate of How appropriate is the interview question: "Show me a piece of code you like"?
    – gnat
    Commented Jul 20, 2015 at 8:51
  • 1
    You didn't specify what is it about code you like. I am not answering your question and I am voting to close it as too vague. The fact is, your prospective wants to make sure that you have a good idea what clean code is and their question is legitimate. If you take issue with that question, your attitude is your problem. If you don't get the question, it's still your problem. If you don't understand something, you follow up for clarifications with the person who asked the question. Commented Jul 20, 2015 at 10:06
  • 1
    Ask if they're referencing the very popular book, "Clean Code"\
    – user8365
    Commented Jul 20, 2015 at 15:24

2 Answers 2


Was this question an appropriate interview question?

"Appropriate" in the context of interviewing, is extremely subjective.

At its core, if the hiring company feels that the question helps them to separate the potentially good employees from all others, then it's "appropriate".

Interviewers toss all sorts of odd questions at applicants. Some seem to be extremely relevant ("We are moving to Technology X and you have experience. Tell me how you might approach rewriting an application that's currently in Technology B?"") others seems wildly irrelevant ("How would you go about finding a needle in a haystack?")

Interviewers can justify for themselves asking almost any question. Often you hear reasoning like "I want to understand how a candidate thinks." Or "I want to see how creative the candidate is." Or "I need to see how they react under pressure."

But many interviewers aren't very good at coming up with effective questions, and ask what they think is clever, what they have read on a website, or what they have been asked in the past. A Senior VP at Google admitted that brainteaser questions are a big waste of time, that they don’t predict anything, but serve mainly to make the interviewer feel smart. (see: http://www.nytimes.com/2013/06/20/business/in-head-hunting-big-data-may-not-be-such-a-big-deal.html)

So as a candidate, we need to try and just go with the flow and accept interview questions for what they often are - an awkward attempt to see if you are capable of handling the position, want to join the company, and would fit in.

While questions might not be effective, whatever the interviewer wants to ask is appropriate (assuming they don't run afoul of local laws).

So "What is your definition of clean code?" is appropriate, even if it may not actually be effective. Once you get the job and learn more about the company's hiring and interviewing practices, you might learn if this particular question is effective in separating the good candidates from the poor candidates, or if it just considered clever by this individual interviewer.


1- Was this question an appropriate interview question?

If you're applying for a developing job, then it is pretty appropriate. Not only because it may be a requirement because you work with others, but also it may be a requirement when you leave to also leave a good code base.

Indeed, it could be pretty subjective. To me, it's just to sound you out, to have an idea of what you consider clean code (and thus, the way you might code). However, it may not go the way the interviewer wants:

I once had a colleague whose idea of clean code was "code that can be read fast". Time proved that by "read fast", he meant "written fast", as in "variables with one character names, loops and conditionals without brackets, big utils files with tons of global variables and functions out of scope".

To me, clean code means the other way around. Self-explanatory variables and methods names, following a standard coding style, trying to split methods in meaningful classes, documenting all the classes, methods and variables so that you can extract a documentation, and also documenting example code on specially important methods.

2- Is this a common question? If so, what would a bad answer to it would look like?

I've been asked directly once, indirectly twice. The indirect ones went pretty well. They were something like:

  • What do you want to see in others' code? (as "I expect you do the same")
  • Do you enjoy coding? (as "you do fine code pieces")

In both cases, I showed some code (unrelated to previous jobs), and they were glad.

The one that went direct was a little less couraging. After I explained that I did all that, her response was something like:

So, you take more time writing than thinking?

They didn't hire me, luckily!

The rule of thumb: Be honest. If you are a developer, tell the way you do. They might like it or not, but you won't have a surprise afterwards, if you're honest.

Not the answer you're looking for? Browse other questions tagged .