home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!news.funet.fi!network.jyu.fi!sakkinen
- From: sakkinen@jyu.fi (Markku Sakkinen)
- Subject: Re: Interesting design/implementation dilemma
- Message-ID: <1992Nov20.110009.19627@jyu.fi>
- Organization: University of Jyvaskyla, Finland
- References: <722091628.F00001@contrast.wlink.nl>
- Date: Fri, 20 Nov 1992 11:00:09 GMT
- Lines: 43
-
- In article <722091628.F00001@contrast.wlink.nl> berend@contrast.wlink.nl (Berend de Boer) writes:
- >Lately when designing two objects, a printer object and a (print)job
- >object, an interesting design dilemma happened. I could choose:
- >1) let the printer object accept jobs, or
- >2) let the job print itself on a printer
- >
- >In Turbo Pascal:
- >1) Printer^.PrintJob(Job); or
- >2) Job^.Print(Printer);
-
- What about conventional procedural style:
- 3) Print (printer, job); ?
- As a comparison:
- in most purely object-oriented languages, any operation _must_ belong to
- one class. This is rather inconvenient in cases like this where
- two or more objects have rather equal roles in the operation.
- If you need multiple polymorphism, the problem becomes severe.
-
- >It happened that I could not choose between these two designs. Turbo
- >Pascal forced me to take the second. Here's how: I wanted the two
- >objects in two seperate units. The printer unit could not be overlaid,
- >but the Job unit could. The Job unit needed to use the printer unit
- >(else how could it print) If I wrote the units this way, the first
- >option gave me an circular reference error. [...]
-
- IMHO, a language that does not allow cycles in the "uses" relation
- between modules is brain-damaged. A person I know was recently highly
- interested in Oberon; one of the main reasons to drop it was that
- Oberon likewise disallows cycles.
- (The Extended Pascal standard, which supports modules, seems to allow
- cyclic export-import realationships.)
- In this special case, one way to eschew the restriction is to apply
- alternative 3 above in a third unit that imports both Printer and Job.
-
- ----------------------------------------------------------------------
- Markku Sakkinen (sakkinen@jytko.jyu.fi)
- SAKKINEN@FINJYU.bitnet (alternative network address)
- Department of Computer Science and Information Systems
- University of Jyvaskyla (a's with umlauts)
- PL 35
- SF-40351 Jyvaskyla (umlauts again)
- Finland
- ----------------------------------------------------------------------
-