Use deprecated library or copy the code I need from it into my codebase?

  softwareengineering

0

I need some code from some deprecated libraries, one small class (150 lines) and two functions (24 lines). The libraries are part of larger set that we use a couple of but both are being deprecated. The packages are still up on the registry but they are removed from the GitHub and not going to worked on or included in future updates.

Given that we are using the latest versions of the rest of the library set, I am considering just copying this code into a small module in our code base and using like such but I wondering what the trade-offs are for this approach.

Since I haven’t started implementing it, I am unsure how much it will need to be modified but I would guess it might require a bit, which is why I lean towards just copying it and integrating.

5

If you’re building something to use longer than a quick throwaway experiment, then it’s asking for trouble to depend on deprecated code, esp. open source code whose source is no longer posted online.

The deprecated library will not get security fixes, bug fixes, or compatibility fixes, let alone new features that you need.

Since you’re on your own already, it’s better to copy the needed source code now and go from there — assuming its license allows that.

The only case I can think of for using the deprecated library is if you’re just testing out whether to use it vs. alternatives.

The remaining choice is whether to include that code in your project or put it into a new library for wider reuse, even if it’s just internal to your organization.

  • The former is easier if it’ll need ongoing changes specifically for this project.
  • The latter is easier if you know of multiple projects that will use it.
  • Otherwise it’s guesswork but you can preserve the ability to package it as a library by keeping it in a separate directory with minium dependencies on the rest of the project.

1

This is a matter of trust and control more than a technical issue.

Some code being deprecated does not mean a lot. Do you still determine whether to update the library or not? Do the authors of the library offer an alternative to the deprecated code and does that fix a problem you may now be impacted by? Do you need more of that library or just those bits? Do you expect additional value to be delivered in future updates of the library, stuff you could use? Do you feel comfortable being dependent on those library developers?

Using external code has trade offs. It is up to you to weight them against each other.

LEAVE A COMMENT