3

I often see questions with code samples depending on external resources (libraries, images). Those code samples are not self-contained, often more complicated to understand, and cannot be turned into executable snippets.

Now, I found such a question and resolved the dependencies by removing them (they were superfluous) and by adding the missing resources to the post (uploading an image).

However, the edit was rejected by the community. Unfortunately, I don't understand why the edit was rejected. When should I make edits to code does not specify whether or not cleaning up external dependencies to make code samples self-contained is an acceptable edit.

IMHO we should be allowed to resolve or remove external dependencies to make other people's code samples self-contained as long as

  • ...the resulting code helps better understand the question
  • ...the resulting code is easier to run, read and understand
  • ...the resulting code still exhibits all characteristics relevant to the question

I think this will help to make questions more appealing to future readers with the same issues and encourages more, better quality answers.

What are your thoughts on the matter?

8
  • 2
    The top answer to When should I make edits to code? addresses editing code in questions. Commented May 31, 2016 at 22:13
  • 1
    I think the moment you remove chunks of code then the reviewers (moving from post to post) will make a snap judgement that you're deviating from the author's intent. Commented May 31, 2016 at 22:16
  • 2
    @BilltheLizard This answer has probably been written before stack snippets became a thing. They are not even mentioned. I think with stack snippets in mind (do they improve 'readability'? they definitively improve the question!) we should clarify the Dos and Dont's.
    – le_m
    Commented May 31, 2016 at 22:20
  • The question and answer were both updated in February. Stack Snippets has little to no bearing on whether or not you should edit the code in someone else's question. The guidelines there still hold up. Commented May 31, 2016 at 22:30
  • @BilltheLizard What is the guideline on cleaning up (either by including or removing) external dependencies in order to turn the code sample into an executable snippet then?
    – le_m
    Commented May 31, 2016 at 22:36
  • Don't change code in other people's questions. You might be fixing the thing that made them post the question in the first place. Commented May 31, 2016 at 22:39
  • @BilltheLizard My question is about code changes that do not fix the issue but expose the issue to more viewers by allowing the code to be run as a stack snippet. Would you mind writing an answer to help me understand your viewpoint better?
    – le_m
    Commented May 31, 2016 at 22:45
  • 1
    My viewpoint is that your question is already answered. Commented May 31, 2016 at 22:48

1 Answer 1

2

Honestly, I think your time is spent on better things. I'm not suggesting that you stop trying to better the site, but that question didn't need any attention. I find that code snippets are mostly useful for debugging questions or previewing what code in an answer does. That is why your edit was mostly superfluous.

It would be a bit different if the question originally had a Snippet and you fixed it. I think I have approved those edits in the past.

You need to remember that each edit you make requires several other people to review it. You should at least try to make it worth their time.

As a reviewer, I know that code edits are likely to be rejected. There have been incidents in the past where code-only suggested edits were used to troll other users, so it's not a completely unjustified mindset. Plus, not everyone's an expert in that language.

You should aim for 2k rep, and then you will be able to edit freely. Of course, you should always use your best judgement.

There are a number of projects on Meta that have already been proposed and received approval from the community. It's best to communicate with the community, and get some other opinions on the matter.

Side note, I actually started my first (and still ongoing) edit crusade slightly before I reached 2k rep: Removing link shorteners from posts! It's far from finished.

Looking over my list of shortening services, I think that flic.kr links are a good choice for you if you wanted to help out. Many of them seem to be still alive, but I expect them to break at any time, so they need to be re-uploaded with the image button in the editor (Imgur has a contract with SE to not delete any images uploaded this way). As always, you should also fix everything else in the post, including grammar and spelling.

You must log in to answer this question.

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