Where Did That Code Snippet Come From?
Join the DZone community and get the full member experience.Join For Free
Have you ever wondered where that code snippet that saved the project (again!) came from? It's probably not a question you'd ask yourself when it's resulted in something being fixed or made to run better. But think back - there's probably a few suspicious snippets in your codebase right now.
Infoworld covered this in a recent blog entry, comparing developers code to the carpenters toolbox. They also mention the problem that this creates
These snippets are often reused unintentionally in a simple cut-and-paste operation without full knowledge of their former or current company's intellectual property (IP) policies. What's more, "the ubiquitous availability of code snippets in blogs and online tutorials poses a bigger risk to intellectual-property hygiene in a company,"
When it comes to keeping to a licence model, tools such as Protecode, which can work as an Eclipse plugin, detects, identifies logs and reports on any external content used outside of a companies defined policy.
There are other problems that exist with these imported snippets too - how maintainable are they, and are they efficient? It's easy for anyone to copy down code from a blog that claims to fix a particular issue, but you have to understand it to maintain it. You don't want to infringe any copyright laws, so you need to ensure you comply with the wishes of the original author, which can be as simple as adding in a comment above the snippet or class.
How much of the code you write is original, and how much is ripped off from some quick searches on Google? Do you have your own toolbox of code snippets? Have you hit any snags from using code snippets?
Opinions expressed by DZone contributors are their own.