home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!wtrlnd!contrast!postmaster
- From: berend@contrast.wlink.nl (Berend de Boer)
- Newsgroups: comp.lang.pascal
- Subject: Interesting design/implementation dilemma
- Message-ID: <722091628.F00001@contrast.wlink.nl>
- Date: Wed, 18 Nov 1992 08:17:46
- Sender: postmaster@contrast.wlink.nl
- Lines: 61
-
- Hello All!
-
- 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);
-
- 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. To see why, here the
- interface sections (simplified):
-
-
- unit Printer;
-
- interface
- uses Job; {* the Job unit reference was only needed *}
-
- {* for method PrintJob *}
- type
- TPrinter = object
- procedure PrintJob(AJob : TJob);
- end;
-
-
- unit Job;
-
- interface
- uses Printer; {* the Job unit needs the Printer unit anyway *}
- type
- TJob = object
- procedure Print(APrinter : TPrinter);
- end;
-
-
- So I had to choose design 2, deleting the reference to the Job unit
- from the Printer unit. (I could choose design 1 but than I had to
- write code especially to circumvent the circular reference error). My
- question is: how far does a particular language (Turbo Pascal in this
- case) influence design? In this case implementation and design could
- not be seperated but had to be considered in parallel. I suppose this
- is very common. For example, one cannot choose a design using multiple
- inheritance if your language does not support it.
-
- Any comments on this design/implementation dilemma would be greatly
- appreciated.
-
-
- Greetings,
-
- Berend. (-:
- fido: 2:281/527.23
- email: berend@contrast.wlink.nl
-
-