R
Robert Klemme
Rhino said:Ahh, now we get to the heart of the issue....
In my case, I have several classes that are writing various formats of
resumes. (Yes, that same project we've been discussing for weeks
now.) The various resume writer classes share a variety of constants,
like the fonts to use in particular parts of the document, the color
palette to use, the name of the log file to use for reporting errors,
etc. I want all of the classes in _this_ project to use certain
values for those things but I don't want all of the classes in _all_
of my projects to use those same values.
It makes no sense to me to define LOG_FILE_NAME separately in each of
10 or 15 classes that use it, particularly if there is a chance that
I may want to change the value of that constant. If my log file is
current "Resume.log" and I decide to change it to "CV.log", I
_really_ don't want to have to change its value in 10 or 15 separate
classes; I just want to change it once and have each class see the
change.
Surely you're not suggesting that I should have 10 or 15 separate
definitions of LOG_FILE_NAME and then have to change each
individually? This seems like a very obvious case for storing these
definitions once - whether in an interface or a class - and then
sharing them amongst all of the classes that need them. Or does OO
propose a different way althogether of handling this very common
situation?
From what you write your constants seem to be rather some kind of
configuration information. In that case I'd consider using Properties
(although they do have some drawbacks as Roedy pointed out; you can of
course wrap them in some class that gives safer / better access to config
values).
Kind regards
robert