// I need to

ModernizeUpgrade without breaking it RescueFix what someone else started Build NewTurn an idea into a product Reach More PeopleGet found, get used, include everyone

// Company

Case StudiesExpertiseAbout + CareersResourcesContact Book a call →
≡articleBuild New

Software Dependency Management: Best Practices

Third-party libraries save time but carry risk. Three rules for managing software dependencies: keep few, audit them, and keep them up to date.

Paul Hendry Jan 2, 20239 min read

Software Dependency Management: Best Practices

Leveraging third-party libraries and frameworks is essential in most modern software projects, and the projects we build at Art+Logic are no exception. The pressure on developers to rapidly deliver features is high, and there are so many commonalities in the details of each project (particularly in Web development) that a lot of development time can be saved by using well-designed libraries that handle the details.

Taking on an external project as a dependency also carries a number of risks however, risks that range from minor to downright catastrophic. Third-party projects can

In other words, while there’s a lot to be gained, there’s also a lot that can occasionally go wrong. A fate suffered by many a software project goes something like this:

  1. At the outset of the project, a few core dependencies are selected. They’re vetted to be well-maintained projects that will remain so for a long time.
  2. As time goes by, further dependencies are added one by one, each solving a particular problem. Whether it’s justified to add them or not, each adds a little more to build times, to application size, and sometimes to application latency. The dependencies are rarely updated, because doing so is behind-the-scenes maintenance work whose value is difficult to appreciate; it incurs development and testing costs without improving the end user experience.
  3. One day, a high-priority dependency-related issue arises. Perhaps the old version of a library stops working and breaks the application until it is updated, or perhaps a critical feature cannot be implemented without the features provided by a newer version of a dependency. The team works to upgrade that dependency.
  4. In order to upgrade that one dependency, other related dependencies need to be upgraded as well. Soon, many dependencies have been upgraded, and many code changes have been made in order to migrate to their new APIs. The process takes many hours, and introduces many regressions because it was done as one sweeping change rather than as individual upgrades that could have been tested more granularly.
  5. What looked like a simple bug or feature request turns into tens of hours of maintenance work, and stakeholders are unhappy.

There is a sweet spot somewhere in between “reinventing the wheel” and “dependency hell”, and while it differs from project to project, it sits closer to the “reinventing the wheel” side than one might intuitively expect. That’s because the positive effects of adding a dependency are usually very immediate (“I had a problem, now this package solves my problem”), whereas the negative effects are delayed (since they mostly relate to long-term maintenance). Consequently, over-use of third-party dependencies is a form of tech debt, quickly solving problems in the short term but causing larger ones in the long term.

In this post, we’ll outline some rules to follow in order to minimize the risks posed by third-party dependencies, with the aim of ensuring the long-term stability of a project.

Rule #1: Minimize the Number of Dependencies

It may be obvious, but the fewer dependencies a project has, the lower the risk they pose. Here are some strategies to achieve this:

Rule #2: Audit Dependencies

All projects ought to be audited before being added as a dependency: this means reviewing the project to ensure that it is secure, well-implemented, and well-maintained.

For NPM and PyPi packages, Snyk Advisor is a useful starting point for assessing a package’s health. It algorithmically scores a package based on things like reported security vulnerabilities, frequency of maintenance, number of contributors, and number of downloads.

Here is a checklist for auditing a candidate (or existing) dependency:

  1. Security
  1. Popularity
  1. Maintenance
  1. Community

If more than one of those boxes is unchecked, then the package is at higher risk of posing future security or maintenance problems, and consequently it should be avoided if a better alternative exists, or else the risks should be communicated to project management and/or stakeholders as appropriate.

Rule #3: Keep Dependencies Up-to-date

Typically, a project’s dependencies should be updated on a regular cadence. This is not just to receive security patches and other bugfixes, nor is it so that developers can have the newest and shiniest features; it’s to prevent the situation described earlier in this post where out-of-date dependencies need to be suddenly and immediately made current, a long and error-prone process that can grind a project to a halt.

Like other forms of technical debt reduction however, it can be difficult to convince stakeholders of the importance of budgeting some time away from immediate end product improvements and towards keeping dependencies up-to-date. At Art+Logic, we approach this topic with our clients by:

As far as the procedure goes for applying updates, the focus should be on doing it as atomically as possible; that is, to do it in small steps and return to a functioning application in between each step. If everything is updated all at once, then in the likely scenario that this breaks the application until some fixes are made, it is much harder to identify the root causes of each bug. A little time spent recompiling and smoke-testing the application in between each upgrade saves a lot of time spent struggling to get a broken application working again.

Final Thoughts, and Language-specific Advice

Often, the biggest challenge with managing the dependencies of a software project is just finding the time or the budget to do it. Since the consequences of letting dependencies gather dust for too long can be so severe however, it’s worth finding a away. It’s also important for teams to always be asking themselves the question: “do we really need this library?” Keeping the dependency list small is the easiest way to avoid complications further down the road.

Each language and ecosystem has its own tools which can help with these efforts. We’ll close out here with a few recommendations for programming languages we frequently work with:

JavaScript

Python

keep going

More to explore in Build New.

All Build New resources →
let's talk

Got a problem like this one?

Tell us what's stuck. A real person replies within one business day.

Talk to our team →

Talk to people who know software, not a sales script.

Your first call is with Aja, our VP of Sales. He'll help make sure you're solving the right problem. Here's what you'll cover together:

  1. What you're trying to accomplish

    The business goal first, then the technology.

  2. Possible approaches

    And the tradeoffs of each, in plain language.

  3. Risks you may not have considered

    Technical and business, before they cost you.

  4. Whether AI changes the math

    What's practical, and what's just hype for your project.

  5. Sensible next steps

    Even if the right next step is not us.

book-a-call.ics

Loading the scheduler…

Open the booking page →

Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include:

  1. What the software does, or should do
  2. What's stuck, or what's worrying you
  3. Any deadline or budget you have in mind
note.md

Loading the form…