According to Frank Heckenbach:
Look at it this way: If there's a field in the base class that not everybody needs, there's no way for those who don't need it to remove it by deriving a new class, so they'll have to carry something useless in their programs.
True.
If, however, a field that some people need is not in the base class, they can just derive their own base class and forget about the old base class.
Sorry, but this is *not* true. I had *lots* of problems with Turbo Vision for this reason.
While generalizing Turbo Vision for graphics mode (thus creating BO3), it was necessary to introduce new fields to `tView'. Since I didn't have the TV source (I didn't want to spend 600DM (~$400) for it (but finally did, you know ...): ), I had to derive successor objects from *each* for-real-use object: `tWindow', `tDialog', `tInputLine', ... it was not only bulk of work, but also very unclean Pascal. Once I had the TV source, I threw away BO3, added the necessary fields to `tView' and essentially re-wrote TV (BO4. My next project of this kind, BO5, will be completely independend of TV (... like BO2 was. I had better continued BO2 rather than trying to use TV ...)).
This example (where to have fields) proves how difficult it is to design a class library for general use. It might be a good idea to introduce some initially unemployed data fields in some base objects just for future use. (Not in *the* base object, but somewhere higher in the hierarchy, where space doesn't matter so much.)
[Some small procedure ...]
(Better declare it as inline, though...)
\begin{off-topic} Or compile it with `-O3', so GPC will automatically inline it. \end{off-topic}
Greetings,
Peter
Dr. rer. nat. [970604] Peter Gerwinski, Essen, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970510] - http://home.pages.de/~gnu-pascal/ [970125]
On Wed, 4 Jun 1997, Peter Gerwinski wrote:
While generalizing Turbo Vision for graphics mode (thus creating BO3), it was necessary to introduce new fields to `tView'. Since I didn't have the TV source (I didn't want to spend 600DM (~$400) for it (but finally did, you know ...): ), I had to derive successor objects from *each* for-real-use object: `tWindow', `tDialog', `tInputLine', ... it was not only bulk of work, but also very unclean Pascal. Once I had the TV source, I threw away BO3, added the necessary fields to `tView' and essentially re-wrote TV (BO4. My next project of this kind, BO5, will be completely independend of TV (... like BO2 was. I had better continued BO2 rather than trying to use TV ...)).
Note that Turbo Vision is *deeply* text-mode and to make it work in graphic mode isn't trivial and require changes in the design of the classes... I tried hard to think of a system that would work nicely both in graphic mode (with proportional fonts and freedom from "character cells") *and* in text mode and I didn't find anything satisfactory.
Pierre Phaneuf
"The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense." - Edsger W. Dijkstra.