[comp.lang.smalltalk] classes vs librarys.

mark@stratix.UUCP (mark) (11/25/87)

	There has been a lot of discussion recently concerned with classes
vs. archives. Basically, I feel that those who think that both methods share
the same basic objective have missed the issue. Libraries provide the
developer with modules that can be used across the system in order to
provide an overall environment for the developed program, insofar as
plausible assumptions may then be made about basic capabilities of the 
system. (eg: Uniform access to files & dos) Classes provide structure
for the system running in this environment, allowing this system to
easily adapt to change.

	Libraries are supposed to be rigid, because of the fact that
they are libraries. As people modify 'libraries' to incorporate class
like behavior (such as qsort in Unix) the complexity of these libraries
rises astronomically, with many library functions really being small
applications systems in their own right.  I have no real objection to
qsort, but with the wholescale modification of libraries I have seen in
order to support 'just one more' variant of a call on a library function,
is barely believable.  The problems with the new systems coming on line
using these resources are all too real.

	Classes are supposed to be flexible, able to call on their
relationships to other classes, and generally serve to provide overall
structure to the end system. This is a somewhat costly operation, even
when a compiler is used, and especially so when classes can be modified 
and extended at runtime.  However, the savings classes produce, because
code for class oriented systems always tends to be described in terms
of the differences from the new system, are considerable, not to mention 
the added reliability of a system that does not contain a great
abundance of duplicated code. 


	So, the basic question is not why classes are better than
libraries or why libraries are better than classes, the question is
when is the use of a class structure or a library function appropriate.	
As a specific example, consider a system that acts as a smart
user interface to some specialized electronic package.  All of the 
different modules of this control system will need to communicate with
this box in some fashion, but the specific organization and content of
these messages will differ wildly. 
	
	In this case, LIBRARY functions serve to provide the common
system capabilities, such as blocked message transfer with error
checking, and the object/class relationships support the multiple 
communications requirements by subclassing, with strong emphasis only
polymorphism, so that all objects can be expected to know what
'updateSelf' and 'updateRemote' mean. Used together classes and libraries
can both make major contributions.  Used in exclusion, you will be forcing
one or the other to do more than they were intended to.

========================================================================
Mark Mullin @ Stratix Inc	AI-SYSTEMS CONTRACTING

USENET:  ..!uunet!stratix!mark   USMAIL:  6808 Dean Dr
CI$   : [71410,1634]		          McLean,VA 22101
MA    : +1 703 847 2046