home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:2988 comp.lang.eiffel:980
- Newsgroups: comp.object,comp.lang.eiffel
- Path: sparky!uunet!mcsun!sunic!psinntp!psinntp!bony1!richieb
- From: richieb@bony1.bony.com (Richard Bielak)
- Subject: Class methods (was: Re: How to design a data structure library)
- Message-ID: <1992Jul23.123609.11699@bony1.bony.com>
- Organization: multi-cellular
- References: <1820@snap> <1992Jul21.124256.17256@bony1.bony.com> <1992Jul22.142916.22115@merlin.hgc.edu>
- Date: Thu, 23 Jul 92 12:36:09 GMT
- Lines: 42
-
- In article <1992Jul22.142916.22115@merlin.hgc.edu> jcm@hgc.edu (James McKim) writes:
-
- [...]
-
- >It seems to me that Union (I think ISE used 'merge' as the verb
- >form of union), Intersection and Difference (ditto for 'subtract' here)
- >are fundamentally binary operations. That is, they're single valued
- >functions of two variables, and so should be designed as such.
- >Thus I favor the c := a + b or c := union( a, b ) form. I would
- >add union, intersection, and difference as a first increment,
- >through inheritance, to the minimal SET class.
- >
-
- The interesting question is which class should the routine "union" be
- in? If a, b, and c are of type SET and "union" is a feature of SET,
- then we have:
-
- c := a.union(a,b);
-
- Which looks a little odd :-).
-
- In Smalltalk lingo, "union" should be a "class method". The essence of
- a class method is that it can be invoked when the object of the given
- class does not exist yet. In Eiffel terms, a class method is a
- creation routine.
-
- Given this, the above call to "union" would be written like this
- (using Eiffel 3 syntax):
-
- !!c.union (a,b);
-
- Which I think is better.
-
-
-
- ...richie
-
- --
- * Richie Bielak (212)-815-3072 | "Your brain is a liquid-cooled parallel *
- * Internet: richieb@bony.com | super-computer". He pointed to his nose, *
- * Bang {uupsi,uunet}!bony1!richieb | "This is the fan." *
- * - Strictly my opinions - | - David Chudnovsky - *
-