37
\$\begingroup\$

A question that asks:

I don't know how to best solve problem X, can you suggest a way?

... is clearly off-topic on Code Review.

A question that asks:

I have solved problem X, and this is how I did it. Is it a good solution?

... is clearly on-topic on Code Review.

There is a grey area in between that is hard to define. There must be a line somewhere. Where is that line?

For example, questions that ask:

... are they on topic, or off topic? Which ones? Why?

Feel free to drop by in this chat room Code Review - Discussion about Help vs. Review if you want to discuss these questions, other questions like this, or just to say "Hi!"

Before answering this question, please read all the above links, and understand some of the background on this problem. Feel free to add comments to the above (and this) questions, and get clarification about other issues in the discussion chat room.

\$\endgroup\$

4 Answers 4

29
\$\begingroup\$

I had the impression that the line is if the code works or not

  • code does not work (i.e. has bugs or does not compile) -> SO

  • code does not exist (i.e. not sure where to begin) -> Programmers

  • code does work (but may not be the best) -> CR

now there may be a grey line between "working code" and "semi-working buggy code", but I think that's a different line than what this question is about.

\$\endgroup\$
6
  • 3
    \$\begingroup\$ If the question is: I don't know how to best solve problem X, can you suggest a way? - and there is code that does solve it in one way.... is the code relevant to the question at all? \$\endgroup\$
    – rolfl
    Aug 21, 2014 at 18:24
  • 7
    \$\begingroup\$ @rolfl because there is code that does solve it in one way, then yes, I believe it is on-topic - although I do see a potential grey line there as well - if a better solution is to scrap the entire thing, then it may not belong here, but without posting it, there wouldn't be any way to tell, so I would still count that as relevant here. \$\endgroup\$ Aug 21, 2014 at 18:27
  • 2
    \$\begingroup\$ @rolfl I don't know how to best solve problem X, can you suggest a way? That sounds like a question tagged "algorithm" on Programmers. Also I think the distinction between sites in this answer is very well done. \$\endgroup\$
    – Mark
    Aug 22, 2014 at 6:08
  • \$\begingroup\$ @Mark You're ignoring rolfl's point in the comment: there is working code and the asker wants a better solution. \$\endgroup\$ Aug 26, 2014 at 19:47
  • \$\begingroup\$ @DavidHarkness still I would say that the comparison between two algorithms is a matter for programmers. The IMPLEMENTATION is what were talking about, so the difference is " how can I solve this problem better" vs "how can in better implement my solution" \$\endgroup\$
    – Mark
    Aug 26, 2014 at 20:24
  • \$\begingroup\$ @Mark Yes, ideally the asker would post two questions: one on CR and the other on PR. :) \$\endgroup\$ Aug 26, 2014 at 21:07
16
\$\begingroup\$

Keep It Simple, Stupid!

That's right, I think we should remember the KISS principle when it comes to our rules.

Essentially, I think this answer says it best but I will elaborate a bit.


I have solved problem X this way and here's my code, but I know there must be a better way! How would you do it?

On-topic. You have solved the problem already, asking for alternative solutions is alright.

It has been stated in the chat room that:

I don't like that we're putting so much weight on the way users are phrasing the plain-English parts of their questions. All other reasons aside, it puts non-native-English-speakers at a significant disadvantage.

I think that sometimes it's just a question of mis-formulation, an OP might say one thing but mean another. For example, when you say "How would you do it?" you might mean the same thing as if you would ask "How could I do it better?"

I think the reason for why someone would ask "How would you do it?" is to find out the answer to "What is the best way of doing it?", which is essentially the same as "How could I have done it better?"


I have solved problem X but it runs slowly, and I suspect that I am not using the right tools and APIs. How do I speed it up?

  • Problem X is solved
  • There's a performance issue

On-topic.

If you say "I suspect that I am not using the right tools and APIs" that's alright, if we were always sure about what we were doing then there would be no need for this site. As long as you got the thing to work, that's all we ask.

Saying that you are unsure about how you did some things in your code is alright, that's almost like you have a semi-complete self-answer already, looking for if people agree with you on that or not is perfectly alright.


I want to build a library of utilities, this is my current API and protocol. Is it good?

I do believe that reviewing APIs can be on-topic. That said, it can sometimes be too less context to actually review it, and I'm not saying that all API questions are on-topic.

Can a bunch of interfaces be 'working code'? Yes. If you have chosen an interface that you feel is right for you, then you can have it reviewed. I do consider an interface itself to be working code, even if it is not technically executable.

Preferably though, you should implement your API before asking here and get the whole thing reviewed together.


I have this code that solves problem X. I don't know if the design is good, can the design be improved?

Not an example question in this meta-question but it is something we have discussed in chat quite a bit. As long as the code does what the code is supposed to do, reviewing design is perfectly alright.

By the way, when I say "design" I think that "design = how the code does it. Method signatures and interfaces are part of the how the code does its job and not the what the code is supposed to do" (in chat I've used the example of calculating probabilities in Minewsweeper)


I am designing an interface for some code. This is what I have. I want it to be able to support functionality X and Y. Will this interface allow that?

Whether or not the interface will allow that is probably something you should know before you ask the question. This sounds like a low-quality question that is probably off-topic, but it is hard to make a final judgement call on that from a simple two-line example question without any code.


Summary

As one of my most common comments say:

Code Review is about improving the cleanliness of existing, working code. Code Review is not the site to ask for help in fixing or changing what your code does. Once the code does what you want, we would love to help you do the same thing in a cleaner way!

That's really the summary of it all. If you have code that does what you want, you're on topic. If you have code that does not do what you want, you're off-topic.

What is 'working code'?

Code that works the way you want it to. Code that produces the results you want.

\$\endgroup\$
3
\$\begingroup\$

I don't know how to best solve problem X, can you suggest a way?

To me is on topic if they provide their implementation.

I don't know how to solve problem X, can you suggest a way?

To me is off topic.

Otherwise, in essence, we are saying that posts from authors who know that their code might not be the best are off topic. That's not right.

\$\endgroup\$
5
  • \$\begingroup\$ As long as problem X already has been (more or less) correctly solved in their code that they put up for review, I agree that it's on topic. \$\endgroup\$ Aug 21, 2014 at 22:04
  • 4
    \$\begingroup\$ "Posts from users who know their code might not be best are off topic." Well then, shut down the site, because that's exactly why everyone posts questions here. \$\endgroup\$
    – RubberDuck
    Aug 21, 2014 at 23:49
  • \$\begingroup\$ I think that asking for how to best solve problem X doesn't sound like the person is asking for code review at all, but for entirely new code (for example a new algorithm). And if they are not interested in comments on their code, but new code, it's not a code review and thus off-topic. \$\endgroup\$
    – tim
    Aug 24, 2014 at 22:30
  • 2
    \$\begingroup\$ @RubberDuck You missed the "Otherwise, we are saying" and "That's not right" parts of the quote. I believe you are actually agreeing with konijn that the part you did quote is not what we should espouse. \$\endgroup\$ Aug 26, 2014 at 21:16
  • \$\begingroup\$ No @DavidHarkness. I didn't miss it. I was emphasising it. \$\endgroup\$
    – RubberDuck
    Aug 26, 2014 at 23:00
1
\$\begingroup\$

For the moment, and until this question is resolved, Code Review will accept questions that are in the 'grey area', so that they can be used as discussion points to identify where the line is, and whether these types of questions create problems for the site in general.

\$\endgroup\$

You must log in to answer this question.

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