Journal Articles
Browse in : |
All
> Journals
> CVu
> 114
(20)
|
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: For Discussion
Author: Administrator
Date: 03 June 1999 13:15:31 +01:00 or Thu, 03 June 1999 13:15:31 +01:00
Summary:
Body:
I wonder whether this would make an interesting discussion topic in C Vu? I've been writing a program for a company that produces monitoring and control equipment for paper mills. Early versions were relatively simple (IMNSHO always a good idea if one wants a successful project!). One of the main features was the ability to display graphs of raw data, either current data or from archive files.
To assist this I made a 'graph' component. To keep my thinking clear, I implemented this as a small class hierarchy. The base class could draw x- and y-axes and plot the data. A derived class knew about file formats and could also step back and forth through archives. A further derivation knew a small amount about two other components (grids that tabulated details, including the graph cursor position), sufficient to send messages to these components to alert them to significant changes.
All well and good, I thought. Indeed, when the company produced an extended file format that added the "smoothed and spiky" versions of the raw data, little work was required to allow users to select these displays.
But when designing a class hierarchy, I suspect it helps if one has a crystal ball handy, to know what kinds of specialisation will be needed. [fade up Jaws music]
At this point the file formats were further extended, and two new displays were required. They both needed a histogram style instead of the pixel-by-pixel graph of the earlier ones. There were some other aspects they had in common, and they still needed to communicate with the two other components.
So my earlier inheritance tree needed (or so I believe) to be turned upside down. I was thankful that the earlier inheritance was essentially an internal convenience and that this wasn't a team project where other programmers might be already using these classes. Adding the new graphs, let's call them MD and CD graphs, my new derivation looked like:
TGraph0 | TGraph1 | TGraph2 | TMainGraph------------------------------------- | | TRawGraph TSmoothedGraph TSpikyGraph | | TXdGraph / \ TMdGraph TCdGraph
But now, (damn, if only that crystal ball weren't so murky) I need to display trend information in yet another window. In some respects this is unlike any of the other graphs. For example, instead of handling data from a single file it collates data from many files. Therefore I suspect I should derive it from TGraph2. Yet in some other respects it is very similar to TCdGraph, especially in the way that it scrolls, reacts to tabset changes, etc.
At the time of writing I haven't decided how to solve this, but I suspect I shall use rather more copy&paste than I like. :-(
I would be interested to hear of other readers real-world experiences, to know if these kind of hierarchy design problems are common and whether I'm overlooking something.
Of course, when you're trying to get nails into wood, it probably helps to know whether there's a nail-gun around or even a hammer. So some may wonder what language I'm using, and others may already suspect that those 'T' lead-ins are a give-away! Yes, I'm using Borland Delphi (and I'm still delighted with the resulting productivity). I'm sorry if some readers feel that makes this off-topic, but I do think that when you're implementing only on MS Windows, if you're familiar with C++ you owe it to yourself to take a look at Delphi (especially so if you've already done some Pascal, but even if you haven't the learning curve isn't steep). I've also bought C++ Builder, and prefer C++ to Pascal, yet I prefer Delphi to C++ Builder, somehow it feels cleaner.
Yes, unlike C++, Delphi doesn't have multiple inheritance, and I suspect that might be relevant here. But if I were implementing this in Java (as indeed I may eventually) doesn't the same question arise?
Notes:
More fields may be available via dynamicdata ..