Wednesday, February 9, 2011

It depends....

Some details may have been changed to protect the innocent naive. 

"So all I wanted was a simple program to send a formatted message over a particular network protocol. Just a little test program.
No problem. I have code that builds that message, it's in a utility library. It'll just take a moment.

Oh, hold on, that code references the Sensor Input Library. I'll just link that in.
Ah, who put a reference to the database code in there. Oh, I see, Yes, they should not have done that, but I guess I see why.

Ok, I'm going to need configuration files so that the database code won't complain.
Right now we are off....
Sort of.

Of course now that I've gotten this far, I finally realise that the Utility Library needs all the network protocols, they are statically linked. Ok, bit of a domino effect, just link in a few more libraries, and a few more.
Right. Done.

Ah, that's not so good, one of the network protocols won't run on this machine. It's a 64 bit machine, and we only have 32 bit libs. No, even though I'm not using it, some part of the code tries to load the dll. 


Each of these dependencies got added on that road that is paved with good intentions. And most likely added in projects which included all these libraries already, so adding them at the time was quietly painless.

Some well meaning refactoring tools even find the projects in your solution as you type in the class name and offer to add the "using" and the reference for you. Here, you go, your first dependency is free.

It's only later when you find that you need a solution that includes 57 separate projects just to write a test program that reads in data from a sensor and writes it to the screen. Then you realise that you are well and truly hooked.

There is a trade off, There is always a trade off. It's often short term win for long term pain.

You should nearly have to get written permission to add a dependency to a library class. Or perhaps be forced to stand up and justify it to your peers, and if the judgement is that you should not add it, the forfeit for the affront to good practice should  be beers / biscuits or breakfast rolls for the team.

And yes, some of the good intentions that pave that road are mine.  And guys, if you are reading this, no, I'm not buying breakfast rolls.

No comments:

Post a Comment