To use a package or to build it from scratch ?

To use a package or to build it from scratch ?

Oct 05 2018, 21:56 in Project Management, Web Development

Many times in your awesome developer life, when you're starting to think about how you're going to build the next feature for a website, you wonder "is there a package for that ?".

And most of the time, there is one! Should you use one, is another question, that we will try to answer.

Let's say you're building a blog. Connected user on your blog may "Like" articles and comments and whatever other model. Should you pull a package that does all of that for you, or should you build it yourself into your application code ?

Let's quickly compare options.

Pros and Cons

Pros Cons
You don't have to think about the implementation You have no control over the code
Takes only a few minutes to install
Most probably bug-free (community testing) If there's a bug or a missing feature you have to wait and hope for a fix
You probably can extend or overwrite methods if needed Sometimes, either you can't, or it becomes a mess.

The winning argument is obviously the gain of time. But, don't forget the time you spent searching for the package. Most of the time there are dozens of packages that do the same things but in different ways, and it takes hours to search for the one that suits the best to your need.

Don't get me wrong here, I'm not trying to dissuade you from using packages, or even to trash talk on them. I love packages and I use tons of them every single day. The goal here is to figure out in which case it might be better to develop the feature from scratch.

In Context

Think about those two situations:

On one hand, you're working on this client project where users can post cooking recipes, rate them and like them. The budget is not that huge so you're main focus will be on the Recipe Posting and listing, searching features etc. The client wants a "Like" feature, allowing users to like recipes. Are you going to use a package to handle this feature ? Probably, because you don't want to lose too much time on this, and you don't want to reinvent the wheel. Also, you probably don't really need to extend the functionnality at all.

On the other hand, you're developing a social network, a Facebook equivalent where users can "Like" approximately anything on the platform. As facebook, you will maybe send a notification when a user like your picture, send an email or whatever. Are you going to use a package to handle the Like functionnality ? Probably not, because you need full control over the liking process, and your business model is build on top of this feature.

Ask yourself those questions

Does this particular feature is a core feature of your application? If so, you most probably want to build it from scratch.

Does the business model of your project rely on this functionnality ? Then just build it yourself. In this kind of case, you will want fully tailored feature that suits your business needs.

Are you trying to solve a particular programmatic issue with style ? Then you probably need a package, because you're not going to reimplement a mathematical solution in your project youself.

For example, if you need to generate a slug string from a model's name in different places of your app, even if it's an important feature of your project, there's a big chance that a package is enough.

Conclusion : of course it depends!

It depends on your business model, and it depends if the feature is part of the core functionnality of your project.

If it's the case, building the feature from scratch will save you time later.

Else, using a package will save you time forever.