Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Where Did That Code Snippet Come From?

DZone's Guide to

Where Did That Code Snippet Come From?

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

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?

 

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}