Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!uw-june!jmaloney
From: jmaloney@june.cs.washington.edu (John Maloney)
Newsgroups: comp.lang.smalltalk
Subject: Re: Software Reuse
Summary: Inheritance is useful for experiments with system classes
Message-ID: <5493@june.cs.washington.edu>
Date: 15 Aug 88 22:53:21 GMT
References: <550@dcl-csvax.comp.lancs.ac.uk>
Organization: U of Washington, Computer Science, Seattle
Lines: 36

Neil,

I believe your question was:

"Does the inheritance mechanism of Smalltalk and other Object-Oriented
programming languages provide significant support for code level
Software Reuse?"

rather than:

"Does inheritance have *unique* advantages over other mechanisms supporting
software reuse, such as generic abstract types?"

I believe the answer to the first question is defintely, yes, inheritance
supports code reuse. I am not sure if it has any advantage over generic
abstract types from the standpoint of code reuse. However, it is
useful when one wants to experiment with a
change to some system class which could potentially have high impact
on many diverse parts of the system. One can instead perform one's experiments
on a new subclass, thus confining the potential damage caused by a mistake.
For example, suppose you wanted to change the behavior of the basic
system-supplied windows ("views" in Smalltalk). If one changed the relevant
system class directly and made a mistake, the system would try to open
a debugger window. However, doing this would encounter the same error
in the window code. This new error would cause the system to try to open
a debugger window and... You would have an infinite recursion which
would crash the system!

Now, if you didn't have inheritance, you'd have to copy all the code for
the system class in question, re-name it, and perform experiments on the
copy. This is certainly not as quick as making a subclass and adding one
or two methods. In addition, using subclassing makes your changes explicit.

Hope this helps.

		-- John Maloney