How a Crowdsourced Code Snippet Library Can Boost Your Open Source Project

Roughly one year ago this month Pippin Williamson made the first commit to Easy Digital Download’s “Library” repository on GitHub. He created the library to be a community-maintained repository of code snippets that modify the default behavior of Easy Digital Downloads.

So far the library has received 113 commits from eight contributors, which has resulted in more than sixty code snippets available to users and developers. The snippets cover everything from modifying the checkout experience to customizing the plugin’s email notifications.

edd-code-snippet-library

With more than half a million downloads on WordPress.org and 150+ free and commercial extensions, Easy Digital Downloads has a large community of developers who work with the software every day.

Williamson said that having the ability to share snippets for modifying EDD behavior has been hugely useful for the project. He only approves solid, tested code but in most cases the snippets have been submitted by the EDD team. Managing the repository hardly costs any time at all, “a few minutes per week at max,” he said.

The benefits of hosting a community-maintained repository of code snippets far outweigh the minimal time required to maintain it. “The biggest problem it has is humans: we tend to forget to put snippets up a lot of times,” Williamson said. He identified three key areas where the library benefits the project:

  • It’s a resource for the support team.
  • It’s a source of examples for people wanting to customize behavior.
  • It provides live testing (similar to add-on plugins) for potential features to add to core.

The most common way that snippets are added to the EDD library is through the support staff. “We write code snippets for customers while helping with support tickets and then we put the snippet in the library,” Williamson said.

He hasn’t seen any WordPress-based open source projects or products doing anything similar but thinks that others could gain some value from implementing a library. GenerateWP might be the closest example of a site attempting something similar for snippets that extend WordPress core, with its new user code library feature. However, this doesn’t have the collaborative benefits of hosting the library on GitHub.

Larger WordPress projects like the Pods Framework, Gravity Forms, WooCommerce, BuddyPress, Jetpack, etc., are prime candidates that might benefit from a library of tested snippets. Of course, it helps that the base EDD plugin is free and open source. A 100% commercial project may not fare as well with a crowdsourced snippet library.

Easy Digital Download is well known for being extensible and developer-friendly. Over the past two years Williamson built a community of contributors 120+ strong and found that extensibility has a direct correlation to profitability. The code snippet library is undoubtedly a valuable investment toward helping developers extend the base EDD plugin.

Could your open source project or product benefit from a community-maintained library of code snippets? A snippet library can keep developers from having to reinvent the wheel when performing common modifications. It also provides a tested resource of code samples for those who are just getting started extending your project. If Williamson’s experience is any proof, then the few minutes per week spent on a snippets library can pay off with a big boost for the community surrounding your project.

Would you like to write for WP Tavern? We are always accepting guest posts from the community and are looking for new contributors. Get in touch with us and let's discuss your ideas.

7 Comments


  1. That’s actually not a bad idea. I use to use the Adobe Air app called Snippley to organize all my Theme Options functionality. The downside to that is risk of losing all your data in a drive failure. I’ve moved most of my snippets over to github and placed private repos on Bitbucket.

    I’ve been dabbling with the idea of just having 1 repo with all my code snippets in them.

    Report


  2. This looks like an excellent idea. Thanks for sharing it. It might be a good idea for other projects to do the same. I particularly like that Pippin maintains some control over what code is included; that will give people a lot more trust in anything found on there and avoid having to wade through a lot of broken code just to find something which does what they need.

    I’m always hunting through folders for code snippets I’ve written previously, so I’ve started adding them to my website lately to make them easier to find for myself, but hopefully others may find them useful too … https://geek.hellyer.kiwi/tools/

    Report


  3. That’s really not a bad idea at all! Our team is in the baby steps of growing and right now we have a bunch of snippets that we share with each other. We have no problems with sharing it with others, we’re totally okay with that, but I didn’t think that it may be beneficial as well.

    Report

Comments are closed.