On using code from the internet

It’s quite common for us, software developers, to search for solutions to our problems on sites like stackoverflow.com, blogs, etc – but what do you do when you find a code sample that suits your needs?

In my case, I always add a reference to the site:


Why bother? In my opinion you can find other useful information such as how to use the code, other useful answers that might be used in a different context, etc. Also, this is a nice way to give some credits to the author, don’t you agree?