Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM design

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: Edwin Goei <edwingo AT sun.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM design
  • Date: Thu, 5 Dec 2002 18:44:44 -0500

At 6:55 PM -0800 12/2/02, Edwin Goei wrote:

As for exceptions, I think users would expect that if the middle call throws an exception, then the state would be just the same as if the middle appendChild() call throws an exception in the non-chained case. So I don't see how this is much different.

That's what does happen. It's not what everyone expects though. It looks like one statement. People expect it to act like one statement. Since it isn't actually one statement, it shouldn't pretend to be one.


Perhaps your main objection is that you think mutator methods should not return anything and not method chaining per-se. Or is it both?

Both. If I had to summarize I'd say side effects are bad. Each public method call should have a single clear purpose which operates completely and independently of other method calls. The normal way this fails is method calls that aren't complete; e.g. you have to call methods 1, 2, and 3 in order to make something happen. They can't be treated in isolation. However, the problem here is the opposite: methods that do too many things that could and should be independent.
--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+




Archive powered by MHonArc 2.6.24.

Top of Page