Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The ability for our software to be used as a drop-in replacement for some other tool is a powerful feature, because it allows the user to replace outdated tools with newer, better designed ones. Designing for replaceability also makes it so that different tools can take different approaches to solving the same problem, which helps prevent project maintainers from having to take a one-size-fits-all approach.
Because Ruby as a language has been historically tied to UNIX-like environments, and because it was built by open source developers, the idea of designing for replaceability seems to be ingrained into our culture. Rather than citing a specific, narrowly focused example, we can see tons of evidence for this in the wild which serve as a reminder that Rubyists value this aspect of software quality:
The Ruby Version Manager makes it possible for us to easily mix and match different Ruby versions and implementations within a single environment, and for the most part you can treat calls to utilities such as
gemthe same way across all versions and implementations.
The Rack Webserver Interface allows users to swap web frameworks while using the same underlying web server or vice-versa in a completely transparent fashion.
The popular XML/HTML parsing library Nokogiri was originally released as a drop in replacement for Hpricot, and was originally meant to serve the same purpose but via a more stable and reliable approach. It later evolved to take on its own unique set of functionality, but it came into existence with replaceability in mind.
Many gems are created which share a common API but use very different implementations under the hood. Often this is to give a choice between the ease-of-install of a pure Ruby library and the performance of a C-extension (such as in the case of Chunky PNG vs. Oily PNG), but this approach can be used for any number of reasons.
As a community, we've embraced replaceability and doing so has allowed us to embrace diversity rather than getting stuck with giant monolithic tools that do everything but don't do any one thing well.
This is the last page of the linear tour. Head back to the Practicing Ruby article to share your thoughts about the topics discussed here.