[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [stellation-res] Return codes considered harmful, and should be eliminated
|
> >-----Original Message-----
> >From: stellation-res-admin@xxxxxxxxxxxxxxx
> >[mailto:stellation-res-admin@xxxxxxxxxxxxxxx]On Behalf Of Dave Shields
> >Sent: September 3, 2002 10:43 AM
> >To: stellation-res@xxxxxxxxxxxxxxx
> >Subject: [stellation-res] Return codes considered harmful, and should be
> >eliminated
> >
> >
> >
> >Several of the comments by Jonathan Gossage in his workspace audit
> >request that the return codes, values, and exit codes be made
> >symbolic.
> >
> >The source of many of these notes was in the definition of command()
> >in the base class Command used for commands:
> >
> > public abstract int command() throws IOException;
> >
> >where the convention was to return 0 for normal completion, 2 if
> >errors, or 1 in a few rare cases. While this usage is common in C and
> >C++, there is no need for it in Java. I had planned for some time to
> >clean this up, and Jonathan's note prompted me to do so.
> >
> >The new definition in Command is
> >
> > public abstract void command() throws IOException;
> >
> >This and all related methods that used to return an int now have void
> >type. It is assumed execution terminates normally, in which case Svc
> >will exit with exit status 0. An error is reported by throwing an
> >exception, which is detected by Svc at the top level, and the exit
> >status is set to 2. The code for 'differ' and 'test' may want to set
> >the program exit status to 1, and this is done by throwing the new
> >exception InformException.
> >
> >There still remains the task of cleaning up, or at least reviewing,
> >the use of exceptions throughout Stellation, but that can be left for
> >a later time.
> >
> >
> >dave
I prefer that myself. I like an architecture where the only time a method
returns a value is when one of its' purposes is to compute that value. I do
tolerate side effects though, unlike in languages like Eiffel.
Jonathan
Personal Email
jgossage@xxxxxxxx
Business Email
jonathan@xxxxxxxxxxxxxx