31

My personal guess... Never.

And yet here(question revisions), a 70k rep user added it to the OP's question. The OP did not create this code themselves.. they created a basic ascii example of what they wanted, but posted no prior attempts. No JSFiddles.. nothing.

I don't want to get into an edit war here, but I was of the understanding that something like this shouldn't have been done.

Am I wrong?

22
  • 22
    I think that unless you're a mind reader, you shouldn't do that.
    – Maroun
    Nov 9, 2014 at 9:46
  • @MarounMaroun I feel the need to ask here; 'you' as in..?
    – Daedalus
    Nov 9, 2014 at 9:49
  • 3
    "you" is anyone.. :)
    – Maroun
    Nov 9, 2014 at 9:50
  • 10
    In their defence, the original ascii sketch is self-explanatory and the added snippet realistically represents an attempt at it. My answer is the only one there, currently, and it would have been the same regardless of the snippets addition. The only thing the edit possibly has done is prevent additional downvotes and closure. Nov 9, 2014 at 11:26
  • 5
    Hehe, clearly he took you up on the challenge to "Go ahead and try it". The fact that you're not happy with the outcome is a strong hint that your comment was unconstructive. It certainly was. Nov 9, 2014 at 12:22
  • If you're creating a canonical question/answer and needed a bit of code to demonstrate it would be a good thing, not just "okay"...
    – Ben
    Nov 9, 2014 at 13:02
  • 6
    The question was being downvoted/closed because it was missing "what have you tried" part. SO does not have a policy about such questions therefore closing it as "why isn't this code working" was unfair (in my opinion at least, since the desired behavior was there). I tried to make the question usable. If there is a problem with my edit I will gladly replace it with what have I tried.
    – Salman A
    Nov 9, 2014 at 15:15
  • 4
    @HansPassant I never said I was unhappy with the outcome, please don't imply that I was. I'm frankly confused on the proper procedure here, since everything I've read up until this point has stated the OP's question should not be edited to include information that was never there in the first place. Secondly, I've been civil in my request for clarification here, and I'll request that you do the same; laughing at me because my earlier comment telling the OP to try something was then answered by another user is rather off color.
    – Daedalus
    Nov 9, 2014 at 22:36
  • 2
    @SalmanA And how do you know the OP hasn't already taken a different approach that doesn't work? Or there isn't some bizzare workplace restriction that needs to be worked around? Don't put words/code in the OP's mouth if it changes the meaning of the question.
    – thegrinner
    Nov 10, 2014 at 15:47
  • I saw the code snippet inserted and it doesn't help much with understanding the question. Just from the original text it is clear what is meant. I wonder really what the code snippet does better than the simple ascii drawing?? Nov 10, 2014 at 16:31
  • 1
    @misterManSam If indeed a lot of user will downvote or vote to close a question without a code sample then I would suggest that the real problem is rather with the users who do that... Nov 10, 2014 at 16:42
  • 1
    @misterManSam Very true. The concern I have is that we don't have enough information to determine what issue the user is having (ex code that throws an error vs final result that looks wrong vs no code at all), so we really shouldn't alter the question in a way that might end up contrary to the user's intent.
    – thegrinner
    Nov 10, 2014 at 16:44
  • 3
    @Trilarion Why is the problem the users and not the person who asked a question with insufficient information? "This question does not show any research effort; it is unclear or not useful" (emphasis mine).
    – thegrinner
    Nov 10, 2014 at 16:45
  • 2
    Related: meta.stackoverflow.com/questions/261165/… Nov 10, 2014 at 16:58
  • 3
    @Trilarion I disagree - all I see from the OP is "I want this layout" with what's effectively an ASCII screenshot. There's no question there. Did he want someone to give him the code to make that happen? Did he have some code that did that but the left and right div were equal (or weren't equal) and he wanted the opposite? Again, there's no question in the question - I would have cast a close vote as "unclear what you're asking".
    – thegrinner
    Nov 10, 2014 at 20:18

4 Answers 4

33

I think that they should not have added code into the question that was not written by the OP. Doing so can be confusing to others, who might think that this is the actual code the OP is using, when it's not.

So basically, never create code to add to the question. If the OP provided a JSFiddle or pastebin or whatever link with their code, it might be appropriate to add that in. But your own code? Nope.

I rolled back that edit btw.

8
  • 8
    Indeed. And if a 3rd party could supply suitable code, then there is a problem is with the people who can't understand it without, and erroneously want close it as a result. People need to get it through their heads that code is NOT always required. Nov 9, 2014 at 20:26
  • 2
    This site is not just for the OP, it's for future visitors. Say somebody asks a question that has nothing to do with the Windows API, but their code contains lots of extraneous Windows API calls. Would you consider it an invalid edit if it was reduced to a MCVE that doesn't require those calls? If the code adds clarity to the question and doesn't conflict with the author's original intent, it's a good edit.
    – user3920237
    Nov 9, 2014 at 20:40
  • 14
    @remyabel Trimming down existing code to be a proper MCVE is a good edit. Making up their own code for the OP and placing it in the question is a bad edit.
    – Scimonster
    Nov 9, 2014 at 20:42
  • 1
    The question is more of a how do I create this instead of why is this not working. MCVE does not apply here.
    – Salman A
    Nov 10, 2014 at 8:49
  • 4
    @SalmanA then why not just give an answer to "how do I create this" instead of making up code?
    – l4mpi
    Nov 10, 2014 at 10:58
  • 3
    @SalmanA Exactly! So it's the place of an answerer to create that code, not for an editor to add it to the question.
    – Scimonster
    Nov 10, 2014 at 11:02
  • 1
    @l4mpi you are correct. And I tried but failed, so tried to keep it open until someone else answers it. The edit was in fact my half hearted attempt at solving the problem.
    – Salman A
    Nov 10, 2014 at 11:06
  • 6
    Looks like the edit war has begun. The rollback has been rolled back.
    – matsjoyce
    Nov 10, 2014 at 21:34
9

Postulates:

  • A good question is better than a poor question
  • A poor question without an mcve can be improved by adding code that fits the error generated
  • The OP of a question can always fix incorrect modifications to the question (possibly replacing code previously added with their own)

Given these, if the error is well enough defined and if someone is able to write code that demonstrates the error succinctly, it can turn a poor question into a good one and thus be appropriate to add in that it makes a poor question into a good one.

Without the code, the question would have otherwise been closed.

Here, the OP had been able to write the code described by the OP:

i want to set three div like that.

second(center) elements(div) set width 1000px other two left right(div) set the rest of browser width.

that exhibited the error or lack of functionality that was described. This then gives potential answers something to work from and also demonstrates to the OP how to ask a question that contains an mcve.

If this doesn't match the OP's code, they now have the template in the question to make the appropriate modifications to show what they actually have.

The edit that added the mcve was a good one.

I will note that adding code like this is often very difficult to read the mind of the OP and generate the code that exhibits the error (and if it does it is likely a dup somewhere). Languages such as markdown and markup (html in this question's situation) are significantly easier to read the plain english text and generate the associated code without having to #include "esp.h".

4
  • 11
    Some errors can be caused by a number of causes. In some cases the breakdown may be: cause A 90% of the time, cause B 9%, cause C 0.9% and cause D 0.1%. Chances are people will edit to add code that reflects cause A, even if the problem is cause D. This will elicit answers that don't fix the OP's problem. How about just closing the question? Sure, the OP can fix the erroneous addition, but closing is exactly designed to prevent having rounds of useless answers before the real cause is edited into the question.
    – Louis
    Nov 9, 2014 at 21:29
  • 4
    @Louis regardless of if it is the problem, can you take a question that is poor and transform it into one that is good (preferably before people start answering the poor question)? If so, it is a good edit. A good open question is better for the site than a closed poor one (which is better than a poor open one). We should endeavor to have more of the first category.
    – user289086
    Nov 9, 2014 at 21:34
  • 14
    You can transform any possible question into a "good" question by replacing all of its content with a "known good" question. Is that useful? No. The point being, you can't simply change the question to make it "better" when this means you might arrive at a different question. Especially when the reason for trying to improve it is "it's so unfair that this post is downvoted and in risk of closure". It was answerable without the code, thus it should have been downvoted (no effort) and answered (or possibly closed as too broad), not edited.
    – l4mpi
    Nov 10, 2014 at 7:18
  • 5
    And regarding "A good open question is better for the site than a closed poor one", closed, downvoted questions turn into deleted questions really fast if people don't rush to answer them and upvote the answers. A closed, poor question that's going to be deleted in a few days is better than an open, slightly-less-poor question that stays around until the end of the internet.
    – l4mpi
    Nov 10, 2014 at 7:21
-6

I must say that the quality of the question is probably the first most important factor. At least from a learning perspective as this site seems to target.

After more than 30 years in this industry, code collaboration is more prevalent than ever. Perhaps not complete sharing on all projects, but certainly in design.

If the context of the question begs for clarity then I see no issues at all to contribute to the postulation, after all, it can often be difficult to ask the question in the appropriate context with the appropriate supporting thoughts and even terminology. This goes back to the days of being told to look up the spelling of a word in the dictionary, when one does not know how to spell the word in the first place.

2
  • Why the down votes with no comments? Not agreeing with a view point does not make it a bad answer.
    – htm11h
    Apr 9, 2015 at 15:47
  • Haven't voted on this answer yet, but it doesn't seem to address the meat of my question. Clarity is one thing; adding code where none existed before is another. Also, not agreeing with the point of view of an answer is a fine reason to downvote. It's not necessarily a measure of how good or bad the answer is, but it tends to happen more frequently on meta, due to the subject matter.
    – Daedalus
    Apr 10, 2015 at 20:34
-8

If the edit makes the question a good one instead of a bad one and doesn't conflict with OP's original intent, it's a good edit.

2
  • Also if the edit is made by a co-worker, or a friend of the original author, it could be a good edit as well. This is my answer to the "My personal guess... Never" made by Daedalus. I don't actually think this is the case here. Nov 9, 2014 at 20:10
  • 7
    @StephanBranczyk any edits to the question need to stand on their own as being appropriate. We have no idea if two users have this type of relationship and can't verify it. Nov 9, 2014 at 20:30

You must log in to answer this question.

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