I was recently reviewing a question, which (if I had paid better attention to the question from the beginning, I may have noticed before answering) had a SSCCE as its primary code example.

At first glance the question is asking which way is the best way to make their UI scalable in the future. I first reviewed their actual code, then gave my opinion on the question they actually asked. I was later criticized for my review on their UI layout, (I assume) because the posted code was an SSCCE.

Should questions which contain SSCCEs be closed as off-topic?

Edit: I see that there are 7 open topics right now which contain the token SSCCE. If the consensus is that SSCCEs are off-topic, should we close all of these. And are there mesaures that can be taken to make it easier to identify posts that have been posted with SSCCE, like having them marked for a review or something. Or perhaps when the user is asking the question, if the post contains the token SSCCE to warn the user that posts with SSCCEs are generally offtopic.

I do understand that in some cases, you may remove bulky repetative portions of code to get to the heart of the code quicker, this question is more directed towards code written as an example


This question is off-topic, but I hesitate to make the generalization that all SSCCEs are automatically off-topic.

The matter hinges on whether the code is an simplified presentation of a more complex problem or whether it's hypothetical code.

This question starts out looking like it could be on-topic. The first implementation works, and the author even provided a helpful screenshot. Assume I will be having a list of 50+ "rows"… starts to push the limits of our real-code requirement, but whether that makes it off-topic is a judgement call. (We routinely handle questions where the author complains that the algorithm scales up poorly for large inputs.)

What does set off alarms, though, are:

  • The second and third implementations are stub code or hypothetical code, as evidenced by the placeholder comments and labels. That is enough to make the question off-topic.
  • The author's refusal to accept @BenVlodgi's review as a valid answer. That attitude runs afoul of our requirement that the author want to accept feedback on all aspects of the code.

    Unfortunately, the feedback-on-all-aspects criterion is often difficult to discern just by looking at the question. I also recently encountered a situation where the OP's attitude put the question off-topic. In both cases, the problem was the OP's

    • insistence that the code in the question was not to be reviewed as is, but that the code actually stood for something else that existed in the author's mind. In a sense, the code became hypothetical.
    • refusal to accept an answer because it "didn't address the question".

In contrast, here is a question that is marginally on-topic, due to the code being a simplification of a real problem — a situation that was boldly acknowledged in the question. However, both parties treated the question as an academic exercise, and there was no fuss.


No, SSCCE's should not be closed as off-topic just because they are SSCCE's.

In fact, almost all code presented on Code Review is some form of trimmed down code to make it fit, to protect the innocent, etc. Many times 'extraneous' parts are ommitted (header files, java import statements, etc.).

An SSCCE is actually a better question than most.

The problem is not the SSCCE, the problem is what happens when the SSCCE is too simple, and does not adequately represent the problem the user is asking help for. Where suggestions from reviewing the code no longer apply to 'the real code' because the SSCCE has abstracted that away too much.

In other words, the SSCCE has crossed a line from being a good representation of 'real' code, to being a bad representation, and the SSCCE is now 'hypothetical'.

So, an SSCCE is reviewable, 'easily'. Whether the review is applicable to the real code is what needs to be determined. Only the asker can do that. If the review does not work, then it is the asker's fault for not making the SSCCE representative.

  • 1
    \$\begingroup\$ I want to agree with you. It's a really good point, but magic question #3. \$\endgroup\$ – RubberDuck Jun 5 '14 at 1:30
  • 3
    \$\begingroup\$ @ckuhn203 - it is about degrees... which makes it a problem. where does the code go from being a reasonable subset of real code, to being too abstracted? I don't know, but I know it when I see it. \$\endgroup\$ – rolfl Jun 5 '14 at 1:32
  • 1
    \$\begingroup\$ That's the rub right there. You know it. Others know it, but when the site graduates and grows, how does the community draw the line. It's a slippery slope. \$\endgroup\$ – RubberDuck Jun 5 '14 at 1:34
  • 1
    \$\begingroup\$ It's not a slippery slope, though. Plenty of other sites are able to have much more subjective topics and criteria. ELU has single-word-requests that are almost entirely subjective for "I'll know the right word when I see it". The Parenting SE is about as subjective as it gets! I think this is pretty tame. Basically, when you find yourself asking for more code to properly review it, there's a problem. \$\endgroup\$ – corsiKa Jun 5 '14 at 14:13
  • \$\begingroup\$ @rolfl I was thinking about this this morning, and your second-to-last paragraph is what hits the nail on the head. In my mind, I was considering "trimmed example vs. contrived example" but "real vs. hypothetical" I think gets the point across just as good. \$\endgroup\$ – corsiKa Jun 5 '14 at 14:16

Well let's look at our 6 magic questions

  1. Does my question contain code? (Please include the code in the question, not a link to it)
  2. Did I write that code?
  3. Is it actual code from a project rather than pseudo-code or example code?
  4. Do I want the code to be good code, (i.e. not code-golfing, obfuscation, or similar)
  5. To the best of my knowledge, does the code work?
  6. Do I want feedback about any or all facets of the code?
  1. Yes (well that one was not too hard was it?) ;)
  2. Yes
  3. NO: SSCCE - Short, Self Contained Correct Example

We can stop here. This question is off-topic as of our help center. Instead of answering, the correct approach would have been to close as off-topic -> stub code and have OP include the real code before reviewing ;)

  • \$\begingroup\$ This is what I thought as-well. I didn't notice it was just an SSCCE til I had already done the deed. And I just wanted to get some peer feedback on the situation. \$\endgroup\$ – BenVlodgi May 27 '14 at 13:46
  • \$\begingroup\$ I have to disagree with the sentiment. First, I'll say I'm the biggest opponent of SSCCE's you'll find. They piss me off on SO like nothing else. That being said, an SSCCE is often production code that has had unnecessary statements trimmed away so they don't distract from the actual question. After all, it has to be short enough to fit into a post - you're not just going to say "here's my github, go read it". I think you're committing what is known as "Equivocation". \$\endgroup\$ – corsiKa Jun 4 '14 at 22:20
  • 1
    \$\begingroup\$ @corsiKa i have to disagree here. The point of a codereview is tk provide a review of all the actual code, not of a trimmed version that removes the really interesting and possibly improvable parts. Also IMO what you describe is not an SSCCE, especially in terms of a codereview. What OP wants to ask about the code is somewhat beside the point, as it would be pointless (I had better, I admit) to restrict the answers in a place where you don't know what the answer is.. \$\endgroup\$ – Vogel612 Jun 5 '14 at 1:12
  • 1
    \$\begingroup\$ @corsiKa - these comments have 'inspired' me to point out the difference between a good, and a bad SSCCE in a different answer. \$\endgroup\$ – rolfl Jun 5 '14 at 1:24
  • \$\begingroup\$ How about when an SSCCE took me about 2 days to create and I am asking for both at once - code & design pattern used review like I did here? Does it make my question off-topic for Code Review? Just wondering now that I've seen this topic... \$\endgroup\$ – user28366 Nov 17 '14 at 11:08
  • \$\begingroup\$ @vba4all Your SSCCE in your question isn't really an SSCCE. It's a stripped down version of your real code, removing some of the nasty parts. I have upvoted your question, btw. The point is, it's understandable that you may not be free to disclose the actual code due to company policies and or privacy reasons. It's like "names changed to protect the innocent", and as such does not fall under the category "Example" imo. \$\endgroup\$ – Vogel612 Nov 17 '14 at 11:18
  • \$\begingroup\$ @Vogel612 cool and thanks for clarification. I guess I need to reread what an SSCCE is then and what the actual difference between a stripped down version is ;) \$\endgroup\$ – user28366 Nov 17 '14 at 11:21

You must log in to answer this question.

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