I have a project in which I created a base class with an inherited
framework regarding a machine Environment, and another class that will
output results to a file.
The Environment class is a base class which is machine dependent, so
all inherited classes basically describe the type of machine.
Initialization for these classes basically determines that the PATH is
set correctly, environment variables exist, etc.
I decided to seperate the Printing/Output functionality from the
Environment, in order to hide directory creation from the environment,
and just in case there needs to be some inherited classes for output
(instead of printing ASCII, I could output in HTML, or something).
The Output class has 2 constructors, a default, and one that takes
a string which determines an output directory.
The Environment class has 2 constructors, a default, and another
that takes an int for debugging.
Anyway, the Environment class will use the Output class to create
some reports. The output class won't be used for any other class,
so I guess it requires an Environment.
The question is, should the Environment class hold an instance of
the Output class, or just a pointer?
If it had an instance, then I would need to create new constructors
in the Environment class in order to pass the string. This seems
kinda clunky, as now I have modified the environment in order to
appease some other class. It does have the advantage of
initialization of all classes at once.
The alternative would be for the Environment class to use a pointer to
the Output class, but the Output class would have to initialized
outside the environment class, and then the pointer set. From a
program perspective, this just takes a couple of extra steps,
but I need to make sure that the pointer is always set.
I may have already answered my question if I want inheritance
for the Output class (the pointer method would work better), but
I was wondering in terms of style if there is a better
style/method/whatever.
---- Posted via Pronews.com - Premium Corporate Usenet News
Provider ----
http://www.pronews.com
offers corporate packages that have access to
100,000+ newsgroups


|