1

I sometimes put a link to the site where I copied a chunk of code from in case I forget what it does. Is this a bad practice? Should I copy the explanation from the site instead of linking to it?

  • 1
    I do the same thing and I usually provide a brief one or two line summary of what it's doing. – Phil N DeBlanc May 15 '18 at 18:43
  • 2
    How do you define "bad practice?" (Note: consider avoiding definitions like "most popular") – Robert Harvey May 15 '18 at 18:43
  • 1
    I would not say it is bad practice, but what do you do when the site changes? I do the same however I also keep a copy (pdf) of the site of really important. – Walter Kuhn May 15 '18 at 18:47
0

I think it depends. if it is obvious what the code does a link is probably not needed. I like to add a link to an article with a brief description of the content, if it is not obvious what is going on or if you deviate from the normal way of doing something or you have a special edge case. Don't forget that internet pages don't stay around forever, that's why I never leave only a link.

Also you should consider if the case warrants that you expand your project documentation.

-3

Is this a bad practice?

Yes.

Should I copy the explanation from the site instead of linking to it?

No.

The correct answer is to document the chunk of code in your own words. This means, instead of simply copying, understand it in order to document it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.