Over a million developers have joined DZone.

Using Private and Final In Open Source Software

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

In recent months I've seen an increase in the use of private and final keywords used in open source software projects. While I'm not opposed to the use of these in writing software, I've noticed a disturbing trend in the reasoning to use them.

Since I started using and contributing to open source software, more years ago than I care to admit to myself, I've noticed one amazing thing. Software is used to build useful things the original authors didn't envision in ways the authors didn't foresee. This is an important concept to remember.

The only way one can know or imagine all the ways a piece of open source software could be used is to peek into the future and know what's happening in the minds of everyone. Can you do that? No... me either.

With that in mind, the use of private and final in software limits the ways software can be used. This is can be useful. If there is a design decision for a good clearly articulated reason not to allow a class to be extended than this makes sense.

If, on the other hand, there isn't a clear reason to make the design decision to use private andfinal than don't use them. By not using them you leave the possibility open for others to do things you couldn't imagine but they could.

This is about enabling others to be successful using what you've open sourced.

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today


Published at DZone with permission of Matt Farina, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

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.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}