Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redundancy vs dependencies: which is worse?

When working on developing new software i normally get stuck with the redundancy vs dependencies problem. That is, to either accept a 3rd party library that i have a huge dependencies to or code it myself duplicate all the effect but reduce the dependencies.

Though I've recently been trying to come up with a metric way of weighing up either redundancy in the code and dependencies in the code. For the most part, I've concluded reducing redundancy increases you dependencies in your code. Reducing the dependencies in your code increases redundancy. So its very much counter each other out.

So my question is: Whats a good metric you've used in the past and do use to weigh up dependencies or redundancy in your code?

One thing I think is soo important is if you choose the dependencies route is you need the tool sets in place so you can quickly examine all the routines and functions that use a specified function. Without those tools set, it seems like redundancy wins.

P.S Following on from an article
Article

like image 855
Chad Avatar asked Oct 02 '08 23:10

Chad


2 Answers

I would definitely recommend reading Joels essay on this:

"In Defense of Not-Invented-Here Syndrome"

For a dependency, the best metric I can think of would be "would the world grind to a halt if this disappeared". For example if the STL of C++ magically went away, tons of programs would stop working. If .Net or Java disappeared, our economy would probably take a beating due to the number of products that stopped working...

I would think in those terms. Of course many things are a shade of gray between "end of world" and "meh" if they disappeared. The closer the dependency is to potentially causing the end-of-the-world if it dissapeared, the more likely it is to be stable, have an active user base, have its issues well-knows, etc. The more users the better.

Its analogous to being a small consumer of some hardware component. Sometimes hardware goes obsolete. Why? Because no one uses it. If you're a small company and need to get a component for your product, you will pick what is commonly available--what the "big players" order in large quantities, hoping this means that (a) the component won't disappear, (b) the problems with the component are well known, (c) there's a large, informed user base and (d) it might cost less and be more readily available.

Sometimes though, you need that special flux-capacitor part and you take the risk that the company selling it to you might not care to keep producing flux-capacitors if you are only ordering 20 a year, and no one seems to care :). In this case, it might be worth developing your own flux capacitor instead of relying on that unreliable Doc Brown Inc. Just don't buy Plutonium from the Libyans.

If you've dealt in manufacturing something (especially when you're making far fewer than millions of them per year), you've had to deal with with this problem. Software dependencies, I believe, need to be understood in very similar terms.

How to quantify this into a real metric? Roughly count how many people depend on something. If its high, the risk of the dependency hurting you is much lower, and you can decide at what point the risk is too much.

like image 113
Doug T. Avatar answered Nov 20 '22 00:11

Doug T.


I hadn't really considered the criteria I use to decide whether to employ a third party library or not before, but having thought about it, probably the following, in no particular order:

  • How widespread the library is (am I going to be able to find support if I need it)
  • How likely am I to need to do unexpected things with it (am I going to end up embarking on a three week mission to add the functionality I need?)
  • How much of it do I need to use (am I going to spend days learning the ins and outs just to make use of one feature)
  • How stable it appears to be (more trouble than it's worth?)
  • How stable the interface is (are things likely to change in the next year or two?)
  • How interesting is the problem (would I be personally better off implementing it myself? will I learn anything useful?)
like image 34
Dan Avatar answered Nov 20 '22 02:11

Dan