tags:

views:

66

answers:

4

Is there an offical way to give reference to some part of the code that does not belong to us? For ex. while posting it to some blog or using for a contest or using on homeworks or in real projects etc etc.

PS: I can do that with comments but I need the official practice. (sorry for my bad english)

A: 

Usually the license of the code you used will dictate how it's supposed to be cited.

hometoast
This is true for large projects but not for code snippets posted in various places like here on SO or library documentation and so on.
Eric
Right. Thanks. I was thinking in terms of 3rd party libraries.
hometoast
All public content on SO is licensed under cc-wiki http://creativecommons.org/licenses/by-sa/2.5/ which requires attribution. Of course if the code posted here has it's own license (hopefully an appropriate citation is made), you'll need to follow that 3rd party license
Michael Haren
The CC requires attribution in the manner specified by the author. How many authors do you see specifying how to attribute their code?
Eric
+1  A: 

"Code snippet after Xyz Abc ([link]) used with/without permission".

Kornel Kisielewicz
A: 

You have to figure out how the code is made available. If you find code posted on the web somewhere without a license you must assume that it's not meant to be used. However, for small code fragments (such as are commonly posted on stackoverflow) I think you're OK. Using code you didn't write in a contest or for a homework assignment is plagiarism (you're claiming it's your work when it's not) and you shouldn't do it. For use on "real projects", i.e. commercially, read the license and see what it tells you.

For things I've written and have posted on my site for reuse, I make sure that each chunk of code has a copy of the license (I favor the MIT license, which essentially says you can do anything you want with the code except claim that you wrote it).

I hope this helps.

Bob Jarvis
A: 

My opinions (IANAL):

  1. If the code is crazy short (<5 lines), it's pretty much up for grabs.

  2. If the code is short (<10 lines), just rewrite it and it's yours.

  3. If you find a sizeable chunk of unlicensed code on the internet, it's best to ask what license it has or for permission to copy it. If the owner agrees or in the absence of a response, I think simple attribution will generally suffice (a comment in the code and save a copy of the response).

In all cases, if a posted license says you can't copy it, or you are denied when asking, I would suggest moving on without taking the protected code.

Michael Haren