I'm working on a project that I want to publish on GitHub. This project requires a specific algorithm Algorithm. Every project I have worked on previously has only used my code (plus STL, etc.), but Algorithm can be a pain in the butt to write, so I want to use someone else's. Algorithm is a small subroutine compared to the size of the rest of my code.
I find a GitHub repository that implements Algorithm, but there is a lot of Junk. By Junk, I mean code I don't need. I want to strip away all the Junk from Algorithm and use it, but I'm not sure how to do that. Ideally, Algorithm could be cleaned off and placed seamlessly within my project directory to reduce dependencies for other users of my project.
I don't know the etiquette for using someone else's code. I don't know how to give credit or what the deal is with all these licenses.
It appears to me that I have five options for how to use someone else's implementation of Algorithm.
includethe original header that declares Algorithm and all the Junk that comes with it. (Do I copy the header and all of its dependencies into my project directory?)- Create a new header and source file that keeps the implementation Algorithm as-is with all comments and
#includethe header into my project (leaving out additional functions and classes that may have appeared in the original header). - Modify the code implementing Algorithm to remove the remaining Junk. Remove comments. Change
Carrays tostd::vectors. Replace pointers with smart pointers. Change thrown exceptions. Remove "options" that my project doesn't need. Change the representation of data to merge everything with my project. - Rewrite Algorithm from scratch, but model it after the existing code, conforming the implementation to my style and making minor performance improvements (nothing that is worth pulling onto the existing repository, however).
What are the rules of etiquette for each of the 4 situations? Where do I put the Algorithm within the project directory? How do I credit someone else's work? How do I credit someone for their modified work (that, for example, removes their original comments)? How do I avoid crediting someone else for work I did (that they may think, hypothetically, uses bad coding practices)? What GitHub features facilitate all this?
Regarding licenses, if using someone's Algorithm to get my code running forces me to publish it with a specific license, can I later implement my own Algorithm and change the licencing? I don't know if I will care to do that, but it would be nice to know.