6

What is the exact policy on Stack Overflow about inserting the poster's code into his question, given the fact that there is an external link to the code in the post?


I've tried to find an official post on the policy about inserting someone's code in his question but really haven't found anything. The only related question I found on Meta-SO is this one, but it hasn't gotten a lot of attention or responses. There is also that question that talks about it and Merlyn Morgan-Graham's answer links to the FAQ. The problem is that the FAQ doesn't not cover this issue directly. Also the latter is more about "should we close the question" instead of "is it legal to edit the code in".

Some sites like Code Review have very strict policies. You can see the following Meta post that states that it's strictly forbidden to copy code into the question there. A lot of edits are rejected there because of that. Here is an example of one edit I made when I was new on the site. Once you know about it, it does make a lot of sense. The code has to be added to the post by the OP.

On Stack Overflow, it's a bit different. There doesn't seem to be any strict policy on that. Sometimes the edit is accepted and sometimes it's rejected – it depends of the reviewers. Though if someones rejects he doesn't really have a Meta post to link to support his rejection.

Recently I've stumbled onto this edit and really wondered if that was "legal" and/or encouraged, in terms of the site policies. On Code Review this would have been rolled-back right away.

3 Answers 3

5

Eh, Code Review is already a highly localized place of business, so it doesn't surprise me that they don't draw code in from external links. If the OP pasted their code into a jsFiddle (or any other publicly accessible place, such as Pastebin), then there is absolutely nothing "illegal" about copying it to Stack Overflow too, especially since it will still be attributed to the OP. Looking at their Meta question, it appears that their reasoning is more that they're against the OP being lazy and they don't want users making it easier for them. Anyways, it's their site so they can handle it how they want.

As for Stack Overflow, we do prefer users to edit the relevant code into the question from external sources. It keeps it all in one place and makes it so users who might want to answer don't have to open external windows, etc in order to do so. The jsFiddle is normally provided as a visual aid, if it's needed.

See: Should I edit posts to pull in the code from jsFiddle?

I should point out, though, that there is no global policy that applies to all of Stack Exchange. It's very much a site-specific policy that each one may discuss if it's relevant to their site. If you can't find a site's policy regarding the matter, ask on their site-specific meta to see what the community prefers.

5

I edit material into the main post from:

  • comments left after the post or on answers by the OP with no sign that the OP intends to edit the orginal post, especially if they change the question (eg commenting on an answer: but I am stuck on XP still)
  • images linked to in the post (new users are limited on adding inline images - I can look at them, confirm they're ok, and put them in the post)
  • code linked to in the post (rarely, but only because I'm impatient/lazy and don't want to do the work of figuring out which bits of it to paste in)

I always include an edit comment such as "brought images inline" so that the OP knows what happened. This is very important if you are only suggesting edits, since reviewers may reject edits that change the post unless (and sadly sometimes even if) you tell them what you're doing.

To the extent that there is a sitewide policy, this is it. I think CR is an exception (I'm completely unfamiliar with it) and by no means the rule. Don't change their meaning, but neaten things up. If that includes bringing in material they linked to, do it.

1

I don't think it's a bad thing to include an OP's code - I've done it a few times in the past, but where I feel adding code turns a basic question into a better one.

They should be doing it themselves, but usually it requires at least one instance of "What have you tried?" in the comments... (I'd be curious to see just how many WHYT comments there are!)

It's partly dependent on what it offers and largely if it improves the chances of the question being answered. Some questions need code - others don't.

You must log in to answer this question.

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