9

Possible Duplicate:
Attribution etiquette in code — do you cite helpful question URLS in code?

If someone answers a question with some code, what's the etiquette for including it (and its technique) in closed source software?

Do you add a comment with a link to the SO question or do you just take the advice and implement the code without any attribution?

Boaz Yaniv really helped me out of a jam with this answer:
Python: override __str__ in an exception instance

...and I want to make sure that my team doesn't think I'm the smart one based on Boaz's inspiration.

Any advice?

3
  • 3
    This should be on meta. Commented May 9, 2011 at 17:22
  • 4
    Man, this is like the first law of coding: only include attribution when the code breaks. :) Commented May 9, 2011 at 17:22
  • This is what comments in your source code are for. Every language worth writing in supports them. Commented May 10, 2011 at 8:47

1 Answer 1

10

It's partly etiquette, and partly good programming, but I'd definitely add the comment with a link to the SO question. Not only is it polite, but it will add context to the code on the off chance that your documentation doesn't answer all questions.

See also this question which addresses the legality: Using code posted on StackOverflow

2
  • 1
    I can't provide any examples but I know for a fact that I've seen someone include an SO comment in their code on a publicly available project Commented May 9, 2011 at 17:27
  • 3
    @Daniel DiPaolo: Google Code Search has zillions of examples of that. Commented May 9, 2011 at 22:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.