On Tuesday 15 January 2002 1:06 pm, you wrote:
> JavaWorld has a very interesting articel on automating creations of
> toString-methods
> (http://www.javaworld.com/javaworld/javatips/jw-javatip99.html).
> The problem I see is that in a project classes continue changing,
> developers adding or removing fields. Doing that the toString() quickly
> gets out of sync with the code it represents.
> Now to the point. Has anyone made a Ant task which takes a class and
> updates the toString based on e.g. a fileset?
>
> Thomas Saxtoft
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

That article goes one step less than one might.  toString is generally not
used in the middle of high activity code, but rather in debug and exception
cases.  In that case why not write it just the once using the Reflection
API on the fly, and then it is always up to date with the current definition
of the class.  As debugging is one of its primary uses, in fact the danger
of not being up to date is even bigger, and doing it dynamically makes
much more sense.  Then this method only needs writing once, and you have
only one place to adjust the formating.

David

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to