3

In this question I posted only the code relevant to the purpose of the question, leaving an MCVE in an external link. Then after a few comments a solution for my question came up from the users, and then I posted the whole code of the MCVE as an answer below, and I edited the answer to point at it.

Is this an acceptable procedure? I mean, even if the solution to my problem came with another user's answer, is it OK to share the whole code as an answer for future reference?

My concern is that it can be lost within other answers and/or a future user can't easily compare the starting code and the improved code.

On the other hand, my concern is that posting the code on bottom the question with an edit may lenghten the question itself too much so that it worsens readability.

4
  • 3
    Since the answer came from another user in a comment, I would have asked that user to make his comment to an answer.
    – BDL
    Jan 22, 2017 at 14:52
  • 2
  • 2
    Your question should have had the MCVE and shouldn't point to or reference an answer at all. (You also don't need to note where you've made edits; the edit history is available as a link below your post.)
    – BSMP
    Jan 23, 2017 at 13:24
  • @BSMP the thing is, in general a CUDA code can't be so minimal. Furthermore, the function there outputs the jacobian, and in the question I tried to "minimalize" it as much as possible, but still it's quite long. I put a link just to the whole routine, and put the relevant part on the question because I was concerned with "readability" of the question. Anyway, the rules are the rules, no more links
    – Eugenio
    Jan 23, 2017 at 14:21

1 Answer 1

0

If a short snippet was enough to properly explain the question, it's also enough to understand the answer.

Stack Overflow answers are intended to answer questions, not be a library of copy+paste-ready code snippets. So there's no need to provide a corrected copy+paste-ready snippet.

If the complete fix is provided as proof that it works, the external link is more useful than the code dump (assuming you link to an online compiler where the fixed version successfully runs). Just beware of retention policy (in practice as well as stated in the terms of service) for those sites so that your demonstration doesn't end up as a broken link. But the answer should contain enough explanation so that it is still valuable even if external links do break / some reader can't visit them due to firewall policy.

You must log in to answer this question.

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