…in the punchbowl

2007.02.06

Too many dependencies

Filed under: c++, nits, programming — Matt @ 8:36

At work I’m integrating a library from our new corporate overlords into an existing application. I use 5 (count ’em, 5) functions from the library. In order to work, the library, which I’ll call libsink, requires between 10-20 other libraries, most of which appear to have nothing to do with the purpose of libsink I am using. This, to use a technical term, smells bad.

I probably wouldn’t care so much if I hadn’t discovered a symbol collision between the libraries on which our application is newly dependent and another library (libgoo) we use. Two different functions, two different libraries, with different semantics, but the same signature — meaning libsink will happily try to use the function from libgoo. Unfortunately, this results in a core dump when the application unloads.

So, if you’re writing libraries (especially in C, where there is only a global namespace):

  • Please keep your dependencies to a minimum; why should I need code to perform higher order calculus in order to print something to the screen?
  • If you’re going to write utility functions that may have names other libraries may use (like, say print() or open()), prefix the function with a string to uniquely identify it and prevent users from accidentally using the wrong function.
Advertisements

1 Comment »

  1. Wow. Now I know how you must feel when I dump too much med-lingo without appropriate explanation. Sounds very intelligent, though…

    (drooling, eye twitching)

    Comment by Erica — 2007.02.07 @ 10:07


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: