If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Code Reuse

Hi Again,

The mantra of code reuse and the claimed benefits have been around since the
days of "structured design", yet study after study reveals that actual code
reuse is quite low, 20% or so. Why do you think code reuse is so low?

To me, it's because code reuse just doesn't work on a large scale. It works
great on small, sharply-focused components, but the larger or more complex
the object is, the harder it is to integrate, debug and test in the overall
system, not to mention being more bug-prone. You end up adjusting the object
to make it fit the new system and then Poof! the benefits of code reuse are
gone.

Granted, 20% reuse can be a significant help on some types of projects, but
it's way short of the reuse nirvana that vendors and academics keep
promising.

Re: Code Reuse

I was just reading an article on Next Generation Windows Services (NGWS) last
night, and the author said that NGWS would finally accomplish the promise
of code reuse. I had to hold back a chuckle because I knew it wasn't true.

The reason why code reuse does not happen is because programmers do not have
a vested interest in producing code that is reusable. It is not that programmers
are not forward-thinking. Rather, they have a problem to solve now, usually
within a budget and a deadline, and planning out a component so that it can
be used in the next ten or twenty projects is just not high on the list of
priorities.

Code reuse does exist, but it exists at the component tools level. All of
the VBX's, OCX's, commercial DLL's, and other ActiveX controls that you buy
from vendors are implementations of code reuse. You buy them once, and you
use them in dozens of projects. The vendors of these components have an
economic interest in providing useful reusable components. When I work on
projects, I do not have that same interest.

In a way, COM really did help to advance code reuse because it provided a
standard way for developers of applications to easily integrate components
made to solve a common problem. I am sure that NGWS will advance code reuse
a little bit more, but we are talking about single-digit percentage points
here.

I once watched a promotional video that showed two programmers building an
application, one on a NeXT workstation, and one on a SUN workstation. The
video was produced by NeXT, and of course the NeXT programmer finished the
project in one-millionth the time of the SUN programmer. Although they never
used the expression "code reuse," they did talk about including pieces already
available on the system (components?) in your program, such as a FAX server
piece. Code reuse existed long before NGWS, long before COM, even long before
VBX's. But I bet the percentage of code developed for a project and reused
has not increased dramatically.

I often reuse pieces of other projects in new projects, but it is generally
at the source code level. I once wrote a great ActiveX control in VB5 that
had all of the features I wanted. But when the Windows Common Controls supplied
in VB6 included much of the same features, I modified my hosting program
to use the Windows control instead of my own. I ended up reusing Microsoft's
code instead of my own, but the application works just great, so the customer
is satisfied.
-----
Tim Patricktim@vbstyleguide.com