programacion-que-son-las-dependencias

What are dependencies in programming

  • 4 min

The dependencies between libraries refer to the relationship that exists between different libraries or packages used in a program.

When a module A depends on another module B, it means that module A uses module B (therefore, module A needs module B to function).

programacion-referencia-a-b

Your module A depends on module B

In principle, including a dependency between libraries is not a bad thing. It’s done every day, and it would be almost impossible to create a program without dividing it into modules.

However, it also has its negative side. If you don’t manage dependencies correctly, your program can become a hell 🔥🔥🔥.

Why are we making a post just to explain dependencies? Actually, it’s quite easy to understand.

Because it’s one of the biggest problems you will have in development. It has always been like this (and I don’t think it’s going to be fixed). So it deserves that we pause and talk about it.

Let’s see a simple example

Let’s see it with a very simplified example with only four dependencies. But keep in mind that in a normal project it’s common to have hundreds of dependencies.

The dependency problem

I think the problem is already visible. Every time a dependency is updated, the entire “chain” of libraries that build up to your application must also increase in version (which is damn horrible).

Of course, you could say “well, then I don’t update, I stay with the old version”. Yeah, but how long will it be until one of the libraries you use, and also uses that library, does update? And then you’ll be indirectly using two different versions and probably… kaboom! 💥

With “this” depending on “this” and “that” on “the other”, it easily becomes a mess 🐔. In the end, if you don’t manage dependencies correctly you can end up with a huge problem.

Remember that the example we saw was very simple with only four dependencies, in two levels. But in a project you could easily go to hundreds or thousands of dependencies and dozens of levels.

Dependencies are evil

So what do we do. Do we avoid dependencies between libraries? No, not that much. In fact, I’ve already said that it’s practically impossible to make a program without having dependencies.

But what you must always keep in mind is that:

  • The fewer dependencies, the better
  • You must have them under control
  • When updating, it can be a headache

To avoid these problems, many tools have been created. Some of which are package managers, versioning systems, and even source code control.