views:

215

answers:

3

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

+7  A: 

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.

Doug T.
Thats a nice metric.Though how many revisions with template meta programming did STL go through?
Chad
Thanks for the edit. Understand what you mean.
Chad
The only problem i see with relating hardware with software. Is because in a hardware system all your components are fixed. Were by in a software system somebody could update a dll or even update the operating system which you have have a dependence to.
Chad
The best example is recently I had an discussion with a friend in the office. We use a DLL for a 3rd party provider. And I was advocating to use a statical lib library to integrate the 3rd party provider source code directly into our code. My reasoning was, if a customer downloaded a new version.
Chad
From the other company web site and updated their dll's our software package would be to blame. Hes advocation was that its more flexible that way. In reality that is exactly what happened! They sent out an update that changed their API behaviour. Such the software packaged worked, but didnt work
Chad
Correctly.So, is it a good metric to have. You build your system with logical dependencies. When a new version comes out you use redundancy to duplicate all new versions until the logical dependencies around discovered?
Chad
Sorry let me fix that.You build you system with logical dependencies. When a new dll version comes out, you use redundancy to duplicate the old dll version. Then with your new dll version of your software you can analysis the new logical dependencies in the new version.
Chad
So i guess the point is, if going down the dependencies chain one need to pay close attention to who owns it, who's supporting it, and for how long.
Chad
A: 

A possible alternative is to use the external software if it provides a lot of value to your project, but hide this behind a simplified (and more consistent to your project) interface.

This allows you to leverage the power of a third party library, but with much reduced complexity (and as such redundancy) in calling the library. The interface ensures that you don't let the specific style of the third party library bleed into your project and allows you to easily replace it with an internal implementation as and when you think that might be necessary.

A sign of when this is happening might be that the interface you want to support is hampered by the third party library.

The significant downside to this is that it does require extra development and add a certain maintenance impact (this increases with the amount of functionality you need from the library), but allows you to leverage the third party library without too much coupling and without all of your developers needing to understand it.

A good example of this would be the use of an object relation mapper (Hibernate\NHibernate) behind a set of repositories or data access objects, or factories being implemented with an dependency injection framework.

marcj
+2  A: 

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?)
Dan