M
Martin Gregorie
I've come to Java from C with almost no formal background or training inLew said:Your reasoning is quite sound. I'd phrase the principles involved a
little differently, but I'd bet I'd come up with the same conclusions.
OOD techniques. In C I've developed a personal pseudo-OO style that just
growed because it minimizes bad interactions. In it I store variables as
control-block structs (very similar to the way that the FILE struct is
used) or as globals with their scope limited to the source file if
there's never more than one "instance" possible per program. All access
to these variables are solely via functions. I also write functions
equivalent to constructor and destructor. The major difference is that,
because the constructor function can return a status code, I'll often do
the equivalent of parsing the option definition string within it. I
think its arguable whether that counts as part of initialization: my
conclusion has been that in C the constructor is a good place to put it
but in Java its often better to split it out.
This seemed like a good place in the thread to check whether this is
sensible, so thanks for your feedback.
I assumed that was what you meant.While I said that constructors can legitimately throw exceptions, I
didn't say they should, necessarily.
>
Which is exactly what it doesThen I'd likely reject that idea and treat null args the same as empty
args, oi.e., no options.
I also use setters to handle seldom used options rather than multiple
constructors. An example would be to turn option case sensitivity on
(default is off).