in reply to OO design question

One way, but bad, is to have a special function for each type of method that you want to print out as for each data type. But this is bad as if you add a new way to print out things, you'd have to add that new way for all object types. Icky.

The better way is to define one output function for each type, with a parameter (a constant) of the method of output that you are generating; it's up to the individual type if it needs to heed that type, with a default output of "plain text". This way, adding a new output type won't break anything to start, and you can then work back to update those types of objects that will work with that data type to do so; those that are unaffected like scalars need no additional updating.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain