Latest / DevQuestions with Tim Corey / 041 How Do I Cite My Code? How Do I Give Proper Attribution?
Transcript
- 0:00SPEAKER_00: Welcome to the Dev Questions Podcast with Tim Corey.
- 0:03SPEAKER_00: Join us each episode as we tackle the questions you are asking about a career in software development, understanding the industry, and new technology.
- 0:12SPEAKER_00: If you're just starting out or you want to grow stronger as a developer, this is the place to get your questions answered.
- 0:19SPEAKER_00: Now, here's your host, expert developer and online educator, Tim Corey.
- 0:24SPEAKER_01: How do I cite my code?
- 0:26SPEAKER_01: How do I give proper attribution so that I kind of protect myself?
- 0:32SPEAKER_01: This is a question that was asked by Kyle, and I thought it was a really great question to touch on in this series.
- 0:38SPEAKER_01: So in this episode, we're gonna touch on how do you deal with using other people's code in your code properly.
- 0:47SPEAKER_01: Okay?
- 0:48SPEAKER_01: So the the question was more in depth than I've so far said.
- 0:53SPEAKER_01: Um there was some more um kind of explanation around it.
- 0:57SPEAKER_01: And one of the things that Kyle said was that he's even a little nervous about using answers from Stack Overflow because you know, that snippet or or that code bit, what do you do there?
- 1:09SPEAKER_01: Is that something you have to give attribution for?
- 1:12SPEAKER_01: Is there some kind of proper way of doing that?
- 1:15SPEAKER_01: And really, it's kind of scary to think that you're putting that in a commercial application if you don't do it right.
- 1:21SPEAKER_01: Okay, so let's talk first about Stack Overflow and other sites like that in general.
- 1:30SPEAKER_01: And you want to check your terms and conditions here.
- 1:32SPEAKER_01: Um, hashtag not a lawyer.
- 1:34SPEAKER_01: Um, but in general, these sites have a Creative Commons license on all the answers, meaning that they are free to use even in commercial applications.
- 1:49SPEAKER_01: So if you post an answer, you can't say, I own that answer, and that answer is mine, and they can't use it for anything else.
- 1:56SPEAKER_01: Okay, Stack Overflow owns everything you post on Stack Overflow, just so you know.
- 2:02SPEAKER_01: Um, and that's not nefarious.
- 2:04SPEAKER_01: That's because they don't want to have a great answer that you say, then you know what?
- 2:08SPEAKER_01: I put that behind a paywall.
- 2:10SPEAKER_01: You have to pay me to get the answer.
- 2:12SPEAKER_01: No.
- 2:13SPEAKER_01: Once you post that, then it you've now given it to the community.
- 2:18SPEAKER_01: People ask a question, you answer the question.
- 2:21SPEAKER_01: That's now usable by the whole community.
- 2:24SPEAKER_01: So that that type of code is available to use freely.
- 2:29SPEAKER_01: So if you want to put it in your code, cool, go for it.
- 2:34SPEAKER_01: Now, if that code has been copied from a source that protects that code in some way, a little bit stronger version than the Creative Commons license, well, you're still protected because you got it off of Stack Overflow.
- 2:54SPEAKER_01: If someone else put the code there, they did not have the rights to do so, that's kind of their problem.
- 3:02SPEAKER_01: Now, you want to be careful here.
- 3:04SPEAKER_01: Again, not a lawyer, um, but if they were to do that, and if you knowingly said, Oh, I know that this is actually the code from Minesweeper from Microsoft, it's not open source.
- 3:16SPEAKER_01: I'm not sure if Minesweeper is.
- 3:18SPEAKER_01: Sorry, side note.
- 3:19SPEAKER_01: But if someone posted the complete source code in Minesweeper on a Stack Overflow answer and you knew that it was protected code, but they had stolen it, you probably shouldn't put that in your application.
- 3:32SPEAKER_01: Okay.
- 3:33SPEAKER_01: But in 99.9999% of the case, the code that's on there is valid to use in your application.
- 3:43SPEAKER_01: Even that 0.001%, unless you know that it was somehow stolen, you're in the clear to use it in your application.
- 3:51SPEAKER_01: So that's that's part one.
- 3:53SPEAKER_01: Now, I would suggest that if you found code on Stack Overflow, first you understand it.
- 4:02SPEAKER_01: Okay, read through it and make sure you know what it does.
- 4:05SPEAKER_01: Don't just blindly copy and paste code.
- 4:07SPEAKER_01: Because if you do, then it's kind of a black box, even though it's open source.
- 4:12SPEAKER_01: Okay, because if it is somehow just works, but you don't know why, then you don't know what it's gonna do if it breaks.
- 4:20SPEAKER_01: Okay, so make sure you understand why it works.
- 4:24SPEAKER_01: But then maybe it's a little tricky because you know, if you're looking on Stack Overflow, it's because it's a tricky problem and you found someone that had the answer to it.
- 4:33SPEAKER_01: But if it's that tricky, what I do personally is I take the URL from where I got that answer from.
- 4:41SPEAKER_01: And Stack Overflow is really great here because you can actually link to the specific answer that you got it from.
- 4:47SPEAKER_01: You take that URL and you paste it in as a code comment above that code and just say, got this code from here.
- 4:55SPEAKER_01: This is not about attribution.
- 4:57SPEAKER_01: This is not about giving the author any type of um kudos or attribution.
- 5:03SPEAKER_01: This is about making sure that you know where to go to the source for the more full context of this bit of code.
- 5:13SPEAKER_01: Because there's probably some explanation around why this code works or what this code goes to solve or tries to solve.
- 5:21SPEAKER_01: So having an additional context can be helpful if you find there's a bug or you're missing something.
- 5:27SPEAKER_01: Because often people will say in the comments down below, oh, hey, it misses this edge case, and there'll be a fix for it in the post.
- 5:35SPEAKER_01: Okay.
- 5:36SPEAKER_01: Now that's just using the code.
- 5:40SPEAKER_01: But if you use code from Stack Overflow, or if you find an answer that points you in the right direction or that helps you, there is one type of attribution that is not required, but I would highly recommend it does not cost you anything.
- 5:57SPEAKER_01: Upvote the post, upvote the answer, post a comment down below that says, thanks, this helped me a lot.
- 6:06SPEAKER_01: Something like that to tell the user that their work that they did for free helped you.
- 6:16SPEAKER_01: That's all it takes.
- 6:17SPEAKER_01: Okay.
- 6:18SPEAKER_01: So you don't have to do it, you're not required to do that, but come on, push the little button.
- 6:23SPEAKER_01: That's all it takes.
- 6:24SPEAKER_01: Do it, okay?
- 6:26SPEAKER_01: Just do it.
- 6:27SPEAKER_01: So that's that's talking about Stack Overflow posts and and those types of things.
- 6:34SPEAKER_01: You can get it from Code Project or other places like that.
- 6:36SPEAKER_01: Um, but you know that that's talking about question-answer sites.
- 6:41SPEAKER_01: Stack Overflow does have a Creative Commons license on all their code.
- 6:45SPEAKER_01: I did uh find that in their their terms and conditions.
- 6:50SPEAKER_01: So now let's kind of switch over to open source projects.
- 6:54SPEAKER_01: So you want to use an open source project in your application.
- 6:59SPEAKER_01: Well, the first thing to do is check the copyright information.
- 7:04SPEAKER_01: So every open source project, pretty much, now there's some exceptions, but GitHub is a big place for open source, and they really encourage you to add a license to every open source project you do.
- 7:18SPEAKER_01: And that license will tell you what you can and can't do.
- 7:22SPEAKER_01: And the really cool thing is that if you're on GitHub and you're looking at licenses, if you click on a license, it will give you the layman's version of what that license says.
- 7:33SPEAKER_01: Now, license agreements are massive and they have all these lawyer words and they can be confusing to read.
- 7:42SPEAKER_01: And I get that.
- 7:43SPEAKER_01: But GitHub links to a site that will give you very clear definitions of what you can and cannot do with any given license.
- 7:55SPEAKER_01: Some you can use freely for um, you know, open source projects or closed source projects or commercial projects.
- 8:03SPEAKER_01: Some you can use for all those things, but you have to make sure that your project, um, if it changes any code that you um include that, I believe.
- 8:15SPEAKER_01: Um, no, there's there's one that says if you use that in your project, your project also has to be open source under that same license.
- 8:22SPEAKER_01: There's a bunch of different license types, okay?
- 8:25SPEAKER_01: But look at the license type, look at that simple definition that will help you immensely in understanding what you have to do.
- 8:34SPEAKER_01: Some of them will say attribution required, and different people have different takes on what that means, okay.
- 8:43SPEAKER_01: But if your application has a README file, put in there thanks to and list the projects that require attribution, or better yet, list all the projects.
- 8:56SPEAKER_01: Why not?
- 8:56SPEAKER_01: Again, what does it hurt?
- 8:58SPEAKER_01: If you're already doing an attribution section, put all the open source projects that helped you get your software off the ground.
- 9:07SPEAKER_01: That's not about greed, okay?
- 9:10SPEAKER_01: And that that's off I hear this every once in a while from people.
- 9:13SPEAKER_01: Oh, open source shouldn't ever have to do anything but be free available for everybody.
- 9:18SPEAKER_01: There shouldn't be any, you know, any money involved, there shouldn't be any attribution involved, because that's just greed.
- 9:25SPEAKER_01: And that no, it's not, okay.
- 9:29SPEAKER_01: There's a lot of work that goes into open source.
- 9:32SPEAKER_01: There's a lot of work that goes into open source.
- 9:35SPEAKER_01: And sometimes the open source maintainer gets nothing in return.
- 9:41SPEAKER_01: Nothing.
- 9:42SPEAKER_01: There may be a little bit of recognition, but that doesn't pay to keep the lights on, doesn't put food in your mouth, that doesn't put a roof over your head.
- 9:54SPEAKER_01: So by having an attribution license, one of the things that that you're providing is at least that the the creator of that project can put in their resume or in their in their portfolio or something like that, references to say this application that I built or this this code that I built is used in boom, boom, boom, boom, boom, all these projects and have a big list of projects.
- 10:23SPEAKER_01: That's kind of a cool thing to see.
- 10:26SPEAKER_01: That's not too much to ask.
- 10:29SPEAKER_01: That's not asking you to give away all your profits for your application.
- 10:33SPEAKER_01: That's just asking you to say, yeah, that person helped me.
- 10:38SPEAKER_01: That's it.
- 10:39SPEAKER_01: Okay.
- 10:40SPEAKER_01: So if you don't have a README for your application, maybe under your help about menu you include that, or include it on your website or something like that.
- 10:52SPEAKER_01: There's different ways to give um give attribution to the people who've helped you.
- 10:58SPEAKER_01: Make sure you take advantage of those things, make sure you do those things.
- 11:02SPEAKER_01: Thank the people that have helped you.
- 11:04SPEAKER_01: Now, some licenses will say this is free to use except in commercial applications.
- 11:12SPEAKER_01: Those are the ones you have to be careful of.
- 11:16SPEAKER_01: Okay, this is not a bad thing.
- 11:18SPEAKER_01: They're saying it's only used for open source.
- 11:20SPEAKER_01: Cool.
- 11:20SPEAKER_01: That's that's their prerogative.
- 11:23SPEAKER_01: Don't use that in a commercial application.
- 11:27SPEAKER_01: It's that simple.
- 11:28SPEAKER_01: Okay.
- 11:28SPEAKER_01: Now you may be able to contact the author and say, Hey, can I buy a license to use it in a commercial application?
- 11:36SPEAKER_01: And you might be able to work something out.
- 11:37SPEAKER_01: Or maybe they have a paid version.
- 11:41SPEAKER_01: For example, um, I showed off EP.
- 11:43SPEAKER_01: That's um a library for working with Excel in C sharp.
- 11:48SPEAKER_01: And they have a license you can use for development and for open source projects.
- 11:56SPEAKER_01: They have a the same code, but you flip one thing to say, yes, it's actually a commercial project, and then you have to pay for it.
- 12:05SPEAKER_01: Okay, do that.
- 12:07SPEAKER_01: That's all you have to do.
- 12:08SPEAKER_01: Pay for the project, and you say, Yeah, I but they're being greedy.
- 12:12SPEAKER_01: No, they're not.
- 12:13SPEAKER_01: Okay.
- 12:14SPEAKER_01: If you're getting money for your application, why aren't you giving them some of your money?
- 12:19SPEAKER_01: Because they're on your team, they're part, they're your employee in some ways.
- 12:25SPEAKER_01: They did work for you, therefore, you should pay them.
- 12:29SPEAKER_01: Okay, so make sure you pay attention to that.
- 12:32SPEAKER_01: But the license agreement should say what to do.
- 12:36SPEAKER_01: The license agreement should be very clear as to what you're allowed to do and not allowed to do.
- 12:42SPEAKER_01: Make sure you check out that page on GitHub, check out the um the different types of licenses, read through them and say, okay, these are the ones that um I want to use or can use.
- 12:54SPEAKER_01: These are the ones I have to give attribution for.
- 12:57SPEAKER_01: These are the ones that I need to avoid in order to make sure I don't violate these license agreements.
- 13:05SPEAKER_01: Okay, there is somewhat of an honor system when it comes to open source code.
- 13:11SPEAKER_01: Don't abuse it.
- 13:13SPEAKER_01: Be thankful for the people who've helped you.
- 13:15SPEAKER_01: Make sure that you um treat them right because they're treating you right first.
- 13:20SPEAKER_01: Okay.
- 13:21SPEAKER_01: So that's my take on attribution.
- 13:23SPEAKER_01: Don't be afraid of it.
- 13:24SPEAKER_01: Don't be afraid of using open source code in your project.
- 13:28SPEAKER_01: Don't be afraid of using code from Stack Overflow or other areas in your project.
- 13:33SPEAKER_01: Just make sure that you pay attention to what those different license agreements are, and then just do what they say.
- 13:41SPEAKER_01: Okay?
- 13:42SPEAKER_01: So thanks for the question, Kyle.
- 13:43SPEAKER_01: It was really helpful.
- 13:44SPEAKER_01: I'm glad we got to talk this through in this episode of Dev Questions.
- 13:48SPEAKER_01: If you found this episode helpful, I'd appreciate if you'd share on your social network.
- 13:52SPEAKER_01: Thanks for listening.
- 13:53SPEAKER_01: And as always, I am Tim Corey.
- 13:55SPEAKER_00: Thank you for joining us for this episode of Dev Questions.
- 13:58SPEAKER_00: Tim is committed to making it easier for you to become a developer.
- 14:02SPEAKER_00: If you would like to help make more content like this possible, please like, subscribe, rate, and share Dev Questions.
- 14:09SPEAKER_00: You can also send your questions to questions at IamTimcorey.com.
- 14:14SPEAKER_00: Until next time, remember, you are too smart and your time too valuable to waste it making all the mistakes Tim did.
- 14:21SPEAKER_00: When you're ready to learn to think and code like a professional developer, head over to IamtimCore.com and enroll in a course.