Paul Hammant a �crit :
> 
> Peter,
> 
> Re recent diffs....
> 
> Generally I am against overriding toString() in classes.  The only way
> you can get the true object reference for debugging is to do a toString
> : "org.apache.Thing@a3b2c3"  That is useful when you are hunting
> problems with multiple instances of a thing or the wrong instance of
> thing.  Of course I am talking of traditional debugging  -
> System.out.println("blah blah " + m_thing).  By overriding toString()
> that is not longer possible.  Perhaps another method name for what you
> are trying to do?  "String debug()"
> 
> - Paul
> 

I agree with your point. Some people in my company also use toString()
to issue full detailed information on the object (many lines). To avoid
this, we now have the following interface :
  public interface Dumpable
  {
      public void dump(PrintStream out);
  }

You can therefore dump(System.err) and also check in dump() if
sub-objects are instanceof Dumpable to dump them either with toString()
or dump().

My .02 euro.

-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com

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

Reply via email to