2.2. Capturing Diagnostics
Alice: Keeping related data in two different places is in itself a bad idea.
Bob: I agree, in principle. In practice, though, sticking them together
is not so easy. We may be flexible and modular and all that, as you keep
stressing, but look, our particle output always takes the form of an ACS data
structure, appearing on the standard output stream, while our diagnostics
output is just free-form, as a string of English sentences, appearing
on the standard error stream. I can't see hot to glue those together.
Alice: Gluing is not the right metaphor; how about encapsulating?
Bob: Sounds nice, but how?
Alice: Of the two forms of output, the particle data are currently most
structured, based on our ACS data format, as you just mentioned. How about
encapsulating the diagnostics information, as a form of short narative,
and adding that to the particle data? We can just call it a story. Each
snapshot could get an extra instance variable @story in the form
of a single long string that contains all the sentences that are reported
on the standard error stream.
Bob: Hmmm, that's an idea. So this would imply an extension of the
snapshot data format. Since WorldSnapshot is a subclass of
Nbody, perhaps it would be better to introduce
@story as an instance variable of NBody ?
Alice: But why stop there? I can imagine that we may want to report
specific information about specific particles.
Bob: I see, you want to allow a story for WorldPoint as well,
or for Body. That makes sense: a particle may want to report
that it had an unusually strong encounter, or even a physical collision,
when we implement that possibility. How about other classes, such as
WorldLine ?
Alice: I suggest that we give every class the option to include a story,
as a way to report diagnostics. In that way, each class can keep its own
diary or chronicles.
Bob: But you still want to get the information out on the standard error
stream, don't you?
Alice: That depends. The usual information about overall error behavior
we probably want to keep on the error channel. However, even that
depends on the application. When we start running 100 runs to determine
first binary formation times, we may not want to see any diagnostics from
any of the runs, unless we have an indication that something went wrong
somewhere.
Here is a bold idea, if I may say so myself. Let us simply give the story
option to each and every object.
Bob: Hmmm, that may be overkill, but then again, it would be nice to
implement it once and for all, and then to forget about it. From then on
it would be ready to use in any situation. I like the idea. Shall we
implement it?
Here is the file acsio.rb. And here is module ACS_IO
that is included in every object. Well, let me add @story as
a recognized instance variable for the top class Object by
adding the information to module ACS_IO. This won't take too
long.
2.3. xxx
Something about getting precision and offset automatically set
Something about keeping clop and acsio independent, so that you can
run one without having to know about the other
using proc and lambda
adding verbosity and acs_verbosity.