Skip to content

The reuse paradox

20120508 (2012 May 08 Tuesday)

A few days ago a college was saying that code reuse has never been made to work, I do not agree. However I do believe that it can not be done to its full potential without Design-by-Contract. But it is nether-the-less done all the time. Her assertion that only a small fraction of code is reused is irrelevant as shown below.

Imagine you have some code of 100 lines. Now 50 of those lines are used more that once. Now we think we can improve this and we refactor the code. Now we have 80 line of code (because of greater reuse) of which 35 are reused (because we mainly improved the bit that already had a lot of reuse). But what does your metric look like it was 50/100=50% (50 lines of no reuse) now it is 35/80=43¾% (45 lines of no reuse). (Note I am not advocating lines of code as a metric.)

What happened? We measured it wrong. The no reuse metric is better, but still not perfect.

No comments yet

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: