Often when I write an answer I write some code to go with it, ie "this method is written a little weird, you could simplify it as X, Y, Z, example". This code is not necessarily always perfect code - it might exclude some error handling, or some edge cases, or just not be written perfectly correct.

I then sometimes get a comment from the OP saying something like "this doesn't work for case T", or "this doesn't compile because of missing semi-colon", or whatever.

In my mind, when I review the code although I may rewrite all of their code to something that is more readable, efficient, or whatever, I never intend for it to be perfectly functional or compilable, or whatever. Rather I generally intend for it to be a general guide as to improving some aspect of the code.

Should I make sure that all of my code works perfectly and solves all of their needs? Should I make an explicit note that my code isn't tested and may or may not work? Should I just ignore people who blindly copy-paste my review and are surprised when it doesn't work as expected?

  • 4
    \$\begingroup\$ I do either, depending on how much effort I feel like putting in. The important thing is to communicate in your review whether the example code is "runnable-as-is" or "just a demonstration". \$\endgroup\$
    – Kaz
    Commented Aug 4, 2016 at 15:34

2 Answers 2


TL;DR; No, but you may get flak downvotes if you don't say it

From my experience Code Review doesn't have any "criteria" for answers, aside from

"It reviews the OP's code and justifies what it says"

Whether that review includes any code, fully functional code, pseudocode or an illustrative example thrown together is not that important. It's generally good tone to mark pseudocode and "demonstration" as such (though that's IMO easily recognizable). Also giving a quick heads up that you didn't test the code is not unheard of, but it's not mandatory, so long as it's not obviously broken.

Adding code is not mandatory in the first place, and OP is not entitled to a review being a free rewrite of their code. As such your code doesn't need to be "perfect".


Code Review is not a code-writing service. Answers are not required to contain code in the first place. The important part of the answer is the advice; the code serves as illustration. However, if you are going to provide code in an answer, you should believe that it is better than the original code in at least some respect. (If I see code in an answer that is worse than the original code overall, I'll usually downvote the answer.)

In any case, when readers evaluate answers, it's up to them to adapt the advice and whatever code it may contain as necessary.


You must log in to answer this question.

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