🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5882

Re: object oriented design decision

#5882
From: Andrew K. Wright
Date: Mon, 21 Nov 1988 14:13
41 lines
2333 bytes
In article <11522@cup.portal.com> dan-hankins@cup.portal.com (Daniel B Hankins) writes:
>This is the tricky one.  This is the one that makes me think that perhaps
>a tree, or even a digraph, is not the proper way to think about classifying
>objects.
>
>What is the proper way?  I'll let you know when and if I figure it out.

The real world is full of all kinds of arbitrary relationships.
If you want to directly model the real world, you will have to
allow arbitrary relations in your language, ie. an arbitrary graph.

The object oriented approach seems to be "the real world is too complicated;
lets fix it (force it into a tree) and then model it".
This works fine when the problem you are trying to model fits
your inheritance tree naturally, but when the fit is unnatural, you
have given the programmer some more work.

An approach which seems to offer more promise of modelling the real world
directly is parametric polymorphism.  Algorithms rather than objects
specify what other algorithms they require to operate.  Universal
and existential quantifiers can be used in the type specification of
algorithms to make algorithms more reusable.  For example, here
is the type specification for "sort", which can sort arrays of any type:

	sort: [ forall t: type,
			forall i: int,
			forall j: int,
			exists >: [t,t] bool,
			       a: [i..j] array t
		  ] proc void;

This says "sort" operates on arrays of any type and any number of elements,
so long as the function ">" is defined between the elements.

This is a simplified example; a general sort would not require the
data structure to be an array.  Sorting linked lists may be equally
desirable, and requires sort to be further generalized to require
that swap (or := and a temporary constructor) exist.
--------
Andrew K. Wright      akwright@watmath.waterloo.edu
CS Dept., University of Waterloo, Ont., Canada.
Technical Details
Message-ID: <9861@watdragon.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watdragon!akwright
References: <4086@enea.se> <11522@cup.portal.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watdragon!akwright
From: akwright@watdragon.waterloo.edu (Andrew K. Wright)
Newsgroups: comp.lang.misc
Subject: Re: object oriented design decision
Message-ID: <9861@watdragon.waterloo.edu>
Date: 21 Nov 88 14:13:32 GMT
References: <4086@enea.se> <11522@cup.portal.com>
Reply-To: akwright@watdragon.waterloo.edu (Andrew K. Wright)
Organization: U. of Waterloo, Ontario
Lines: 41