I used code from a published Masters thesis in my PhD work. I have modified just 10% of the code to suit my research requirement. However, most of the code is as developed by the original researcher. I had to use the code from the literature because I currently don't have the time, the resources or the motivation to write the code from scratch.

However, I am in a dilemma whether I am doing something unethical by using code developed by someone else for my research. I will cite the original thesis in my papers and thesis. I will cite it in the following manner:

The code used in this thesis has been developed based on the work published by John Doe at the University of Agartha [1].

[1] Doe, J. Implementation of a code. University of Agartha, 2008.

Also, I am not going to add the code in my thesis or my paper. Will this be unethical and violation of the original author's copyright?

  • 10
    Under which licence has the code been published? Most likely, the original author published the code so that you and another researchers can work with it.
    – J-Kun
    May 25, 2019 at 6:11

3 Answers 3


There are three issues:

  1. Is it a copyright violation? This depends on the license under which the original code was released. You'll have to read it.

  2. Is it plagiarism? No, you have credited the original author. However, you may want to make it more clear that it is really a relatively minor modification of their code. Your current wording, "developed based on work...", could be interpreted as "I got some ideas from their work but then wrote all my code from scratch", which would misrepresent the real contribution of the other authors.

  3. Is it adequate for your PhD thesis? You could write an entire thesis that just used the work of others, appropriately cited, with minor tweaks. It wouldn't be plagiarism, but it also wouldn't get you a PhD, because it doesn't demonstrate an ability to do independent research. So, you need to make sure that your advisor and committee are fully aware of what parts are your own work, and what parts are the work of others, so that they can evaluate your research accomplishment based on what you did. If they don't feel it's adequate, then you may have to do more work in order to complete a thesis that will pass.

    The same applies when you publish a paper. Here, the editors and reviewers need to evaluate your paper based on its novelty - what part of it is new work, versus what simply makes use of existing work?

  • 2
    Copyright isn't involved if the code isn't published.
    – Buffy
    May 25, 2019 at 10:42
  • 7
    @Buffy No, you also need a license to use the code. The question asks about the ethics of using the code, not writing a thesis about it. May 25, 2019 at 11:42
  • 1
    Good answer, I’ll add that when referencing code it’s fairly standard to provide a link to the public repository from which you got the code (eg GitHub)
    – Spark
    May 25, 2019 at 12:20
  • 1
    "a relatively minor modification of their code"; actually, that would depend on what the 10% does (and how 'critical' it is); if the 90% is just doing UI, data formatting and parsing and what-not, while the 10% is the part that's actually doing the actual analysis work, well, that 10% change would be, in fact, a major change IMHO...
    – poncho
    May 25, 2019 at 17:01
  • 1
    @Buffy If the code isn't published, all rights are reserved by default. Aug 6, 2021 at 14:22

No, it is not unethical. If the original authors didn't want you to use the code, they would not have made it public. In fact they're likely to be flattered that you find their code useful/interesting enough to make use of it.

Of course, you need to cite the original authors, since you're using their work.

  • 3
    It depends what license they released it under.
    – Elin
    May 25, 2019 at 9:06
  • 2
    @Elin, not for use.
    – Buffy
    May 25, 2019 at 11:23
  • 1
    OP is not using, OP is modifying. And licenses can be about use, it is just that some licenses are more focused on distribution, e.g. the GPL license to you gives you the license to redistribute under certain conditions. It also gives you license to run, study and modify.
    – Elin
    May 26, 2019 at 8:38

Disclaimer: I am not a lawyer.

But what you suggest is fine unless the code has been patented. That is very unlikely, of course.

Distinguish between using something (permitted - unless patented) and republishing it (depends on license).

The only time in which you can't use something is when it has been patented but not licensed to you. I doubt that is the case here. But otherwise you can use what you find and you can use modifications of it. You just can't republish the work of others without some sort of permission such as a license.

Plagiarism is a different issue than publishing/copyright. If you cite the work you are correctly attributing it to the source and so avoid plagiarism.

Think of an analogy with mathematics. If I find a (copyright) formula in a math book, I can use it. I can even adapt it for other use. I can't claim that I created it (that would be plagiarism) and I can't republish it without permission. If this were not the case it would be impossible for mathematics to advance. Every formula or other idea would be an absolute block to every other mathematician.

Think of an analogy with poetry. If I find a poem published somewhere, I can adapt and rewrite it for my own purposes. I just can't republish it and I may not be able to publish my rewrite. But I can use it myself, perhaps for my own enjoyment.

Code is a bit different since it can be executed. If I find it and it isn't patented, I can execute it. I can also rewrite it for my own purposes. And I can execute that also. I just can't republish it necessarily. And whether I can publish the changed code depends on things.

For reproducibility purposes you can publish how you changed the original because that is your work, but you may not be able to publish the complete version you used since it is in part the work of another, but that depends on the license.

Patenting code is extremely problematic in my view. Unfortunately it is possible to do it in some places.

Note that I've assumed that the program code is published as text, not as an executable. I've also assumed that you have legal access to that text.

Note also, that I've assumed that it isn't a "trade secret". If that were the case then you wouldn't be able to even see it without (probably) signing an explicit license setting out terms. But holders of trade secrets have to do due diligence in keeping the work "secret".

  • You are assuming the author has legal access to the code/book/poem in the first place. I wish you were right, but you're not. Your profile says you are CS professor. I would guess you have read the EULA on commercial software and seen all the restrictions it places. Your institution probably pays for licenses that do not follow the rules you have described in your answer. May 25, 2019 at 11:47
  • 1
    @AnonymousPhysicist, yes I make that assumption. I think that is fair for something (computer code) "published in a Masters thesis". It is quite different for things not published as source but only as executables.
    – Buffy
    May 25, 2019 at 11:50
  • 1
    @AnonymousPhysicist, Computer science textbooks are usually published with "all rights reserved". They contain code, like the "hello world" program. Is a student being unethical for entering that program and executing it? For adapting it to "hello universe"?
    – Buffy
    May 25, 2019 at 12:05
  • 2
    @AnonymousPhysicist, note that commercial entities use "trade secret" to protect their source code. By publishing executables the only way to "use" it is to circumvent copyright and the only use of the copy is to execute it. That isn't the same for the source code which has other uses, such as learning from it. If you have a legal copy of the source you can use it for all legal uses including execution. But you can't publish it or publish adaptations without license. Source code is just text.
    – Buffy
    May 25, 2019 at 12:11
  • 2
    @AnonymousPhysicist, also note that EULA agreements are about contract law, not copyright law. And, since they are restrictive, not permissive, some courts have ruled that some such "agreements" are not enforceable, being improper use of contract law. Confusing these things isn't helpful to the OP. Note that copyright license is, by its nature permissive. You can't impose added restrictions through a copyright license. Contract law is quite different.
    – Buffy
    May 25, 2019 at 12:24

You must log in to answer this question.

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