21

Edit: This question was originally asked for SQL fiddles. But i believe that this is more generic and applies to all fiddle type solutions.

Many times a question demands a fiddle to demonstrate the solution.Is it OK to use another answer's fiddle as starting point and work on top of that to save time and to deduce and post an answer quickly.

Sometimes user copy a fiddle and make minor corrections and post it as answer.

Example in light of SQL fiddle-

A SQL fiddle consists of schema and test data creation script and a solution/query which provides the desired results.

So my question is it OK to copy another answer's SQL fiddle specifically the schema and test data creation script to quickly start working on solution/query part.

16
  • 23
    I don't see why not. Isn't that what we [developers] do anyway?
    – CubeJockey
    Aug 7, 2015 at 19:35
  • 6
    Is the content of sqlfiddle licensed in some way? On SE you'll need to do the attribution.
    – rene
    Aug 7, 2015 at 19:35
  • @rene I went through their About page and could not find any indication. sqlfiddle.com/about.html
    – DhruvJoshi
    Aug 7, 2015 at 19:39
  • 2
    We better wait for a lawyer...
    – rene
    Aug 7, 2015 at 19:46
  • 4
    I think test data is test data, any body can use that. Aug 7, 2015 at 21:33
  • 2
    I've never been that convinced that SQL is code. But it is on topic at SO so it must be. Which makes the fiddle subject to the site license rules, link to the original post and link to the author's profile required. Sorry :) If you want to skirt that requirement then you'll probably get away with it. Aug 7, 2015 at 22:19
  • 22
    For starters, whatever you do, don't go claiming you wrote the fiddle yourself when you know you didn't.
    – BoltClock
    Aug 8, 2015 at 5:39
  • 3
    I agree, as long as one does not claim ownership / creation of the code; I think it's fine. Aug 8, 2015 at 11:19
  • 3
    If the SQL Fiddle is just setting up DDL for data shown in the question then it is going to be indistinguishable if you create it yourself or not as the final code will be the same. Aug 8, 2015 at 11:21
  • 5
    @HansPassant: Why would SQL not be code?
    – ruakh
    Aug 9, 2015 at 4:02
  • 4
    @HansPassant: It doesn't matter. SQL is content. Aug 9, 2015 at 16:19
  • You can use, but give credit where 'tis due. Aug 10, 2015 at 0:03
  • @ruakh If it doesn't have a Turing Complete type system, it isn't really a programming language, is it? Aug 10, 2015 at 2:34
  • 2
    @BoltClock the weird dark spot in that image had me terrified something awful had happened to my laptop screen, how did that even get there?? Aug 10, 2015 at 15:07
  • 1
    @oxguy3 it's a ghost-image of a thumb, from holding the original down on the photocopier. Aug 10, 2015 at 17:16

1 Answer 1

22

Yes, this is absolutely OK: fiddles are meant to be fiddled with.

I don't mind when others take a fiddle I've created as a base for theirs - this is one of the reasons I post fiddles, and why they are useful. It saves the boilerplate of creating them.
A fiddle isn't something you should be protective of nor proud of - it is not the answer, it just accompanies the answer.
In addition, the data and schema in the fiddle probably originate from the question anyway.

There are other cases when fiddles are useful:

  • As counter-example to an answer.
  • Trying to reproduce the issue in the question.
  • Sometimes we encourage the poster to add a fiddle.
  • Sometimes when I try to solve a question and don't succeed, I still post the fiddle as a comment so others can pick it up.

These fiddles are posted as community service, with full intention they will be expanded and used by others. I don't see why fiddles posted in answers are different.

Should you give credit?
It depends. You are using something from another answer while adding your own - this is a competitive scenario, and some people might get overly protective of "their" fiddle. An acknowledgement you've used it as a base may defuse this feeling.
It also helps to add more edge cases or sample data. If you're adding a new answer, it should be better than the existing answers.
On the other hand, in my opinion this "credit" usually gets in the way. For example:

Working example (based on User's example): http://example.com/fiddles/he2V9

I usually use comments for this credit, it isn't really part of the answer.

I would upvote the other answer - it is probably a good answer if it is supported by a working example.

However:
While I am liberal with the usage of fiddles, including their schema, sample data, and test cases or asserts, I would not use anything from the actual solution.
This isn't a real restriction because you are not shamefully copying another answer or adding a trivial improvement, you are suggesting a different solution, but it should still be said.

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