I am just getting into using Github to showcase my code to potential employers. The primary use of my Github is really just to show employers my coding ability.
What is the right thing to do when I copy and paste a chunk of code from a site like stackoverflow? Should I add some sort of a comment?
Here is an example
I am looking for a fast way to calculate the ceiling of an integer division and copy and paste an answer into my code and upload it to Github. Should it look something like this?
q = (x + y - 1) / y;//taken from https://stackoverflow.com/questions/2745074/fast-ceiling-of-an-integer-division-in-c-c
Or I want a function that compares floats to double
/*function found at https://stackoverflow.com/questions/17333/most-effective-way-for-float-and-double-comparison*/
bool AreSame(double a, double b)
{
return fabs(a - b) < EPSILON;
}
At work I know other people copy from Stack Overflow to solve a problem and I don't consider this immoral. But I do feel unfair if I copy it, put it on my Github and use it to get hired.
Considerations:
- I try to understand the code that I'm copying.
- I can try to obfuscate that I copied and rename things but this doesn't make it feel fair to me.
- I can somewhere mention that I get answers from SO
The above examples are fairly small but I have seen larger segments of code offered on other sites. I mean I'm not going to copy a full program and make it look like my own, but where is the line crossed from "inspired by someone else's code" to copying it? I don't consider changing around variables to really make it better.
So I'm asking 2 questions
- When should I cite a function that is more or less copied?
- How should I do it?
* Search through an array of objects to see if a given index matches a given value * http://stackoverflow.com/questions/4742903/php-find-entry-by-object-property-from-a-array-of-objects
I modified the method slightly from what's there, but if I or another developer ever need help with what's going on, and why I chose that code, we know where to look.