Keep your web project dependencies under control

These days almost any project we work on relies on dependencies (sometimes too many) on which we need to keep our eyes on. In general - in particular for big projects - can become a challenge to keep things under control as the projects evolve over time. If we consider the most common needs for web development we know that we need to have a good number of libraries and frameworks around.

Why we need them?

Dependencies are not a bad thing - we need them - and it’s a way to share code, reuse and most importantly - in most cases - to avoid reinventing the wheel over and over. I’m a bit more focused on the needs around web projects but similar lessons and ideas are valid to many other contexts.

When to introduce a dependency?

Every time we need to solve a problem that is already solved and there is no existing code on the current project is in general a good idea to add an existing dependency if it not falls on When NOT to introduce a dependency? below. It does not matter if it is 3rd party or from our internal packages repository - let’s say NuGet/Bower for the sake of a clear example - if the problem is already solved let’s not repeat ourselves and let’s keep our focus on delivering what we are building and trying to deliver.

When NOT to introduce a dependency?

When the problem you need to solve is on the reach of writing a small function - even if you need to reuse it across your project - and/or when your are building a new package or library to distribute around, it is always a good idea not to introduce more dependencies.

A good example is if we are building a JavaScript component/utility to share across our company projects or even to make it available as open-source, not adding external dependencies facilitates our code distribution with less friction. No one likes to add dependencies that come with a lot of ballast.

Wrapping up

  • We all know this: less dependencies is less requests, less request sizes and faster load times. No brainer.
  • Keep the amount of dependencies as low as possible. Less moving part less risks;
  • As the number of dependencies increases as well the amount of work required to keep them up to date will increase over time. Take AngularJS, Angular UI, ui-router - and related - as a good example;
  • Avoid adding full libraries for additional limited functionality that we plan to use on a limited context/scope in your project;
  • It’s always a good idea to solve any problem writing the less code as possible. Adding the minimum number of dependencies as possible is also a good way to keep our feet dry.

This is all based on what I’ve experienced over the years and feel free to consider as completely subjective if this does not fit your expectations or experience.

Tags// , , ,
comments powered by Disqus