home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:3057 comp.lang.eiffel:1019
- Newsgroups: comp.object,comp.lang.eiffel
- Path: sparky!uunet!wupost!usc!rpi!psinntp!psinntp!bony1!richieb
- From: richieb@bony1.bony.com (Richard Bielak)
- Subject: Commands and Queries (was Re: Class methods)
- Message-ID: <1992Jul29.124608.8707@bony1.bony.com>
- Organization: multi-cellular
- References: <5631@vexpert.dbai.tuwien.ac.at> <1992Jul28.150114.25065@bony1.bony.com> <STEINMAN.92Jul28184519@hawk.is.morgan.com>
- Date: Wed, 29 Jul 92 12:46:08 GMT
- Lines: 51
-
- In article <STEINMAN.92Jul28184519@hawk.is.morgan.com> steinman@is.morgan.com (Jan Steinman) writes:
-
- [...]
-
- >I think the hang-up on queries or commands is getting in the way here,
- >as is the class-object distinction. Objects are created continuously
- >and rapidly; many messages need to return newly created objects, and
- >if you insist that only classes can return new objecs, you'll get in
- >trouble quick!
- >
-
- Isn't "new" a class method in SmallTalk?
-
-
- >If you must think in terms of categories of messages, how about adding
- >a third: "collaboration". aMan and aWoman collaborate to create aChild
- >-- they don't ask either Manness or Womanness to do it for them!
- >Likewise, "3" and "4" can collaborate to create "7", "1", or anything
- >else that is legal among consenting adults.
- >
-
- One of the reasons why commands and queries are attractive, is that
- they extend nicely into the realm of concurrent objects. Since a query
- does not change the state of the object, many queries can be active
- within an object at the same time. On the other hand, only one command
- can run within an object, as it changes its state.
-
- This distinction also fits nicely with Eiffel's assertion mechanism.
- The pre-, and post-conditions and the invariant remain valid in a
- concurrent object.
-
- In your example of aMan and aWoman, who gets the message to create a
- child? I guess to be politically correct, the statement would be:
- aChild = [aWoman mate: aMan] ( ;-) ).
-
- Collaboration is a nice idea, but even in your example, it doesn't
- tell me where to place the method. Or am I missing something?
-
-
- ...richie
-
-
- P.S. Shouldn't we have aChild = [Child dad: aMan mom: aWoman] ?
-
-
-
- --
- * 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 - *
-