[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Greenspun's tenth law rears its head: was InnerXml is like


c append

> From: Elliotte Rusty Harold [mailto:elharo@m...] 
>
> Hmm, I'm willing to consider whether append() alone might be 
> sufficient instead of "appendChild" but I think "append" is 
> demonstrably better than "add".

Yes it is. The answer to your consideration is in the question: can I
add anything other than a child node?

 
> Your suggestion is pretty good, but I'm hesitant to rely on 
> indentation to convey meaning. 

Granted. If you go wild with nested append calls combined with embedded
constructors, you will depend on whitespace. You always depend on
whitespace, but especially so there; much the same way as you would to
make anonymous inner classes readable. Chaining append() calls doesn't
impose the same level of care:

 Element a = ...;
 Element b = ...;
 Element c = ...;
 Element d = ...;
 Element e = ...;
 d.append(a).append(b.append(c.append(e)));

is not imo unreadable, more importantly it can be made idiomatic:

 Element a = ...;
 Element b = ...;
 Element c = ...;
 Element d = ...;
 Element e = ...;
 c.append(e);
 b.append(c);
 d.append(a).append(b);

I wouldn't consider making a developer choose between either of those
and this:

 Element a = ...;
 Element b = ...;
 Element c = ...;
 Element d = ...;
 Element e = ...;
 c.append(e);
 b.append(c);
 d.append(a);
 d.append(b);

to be a feature in an API. Each to there own comprehension. My
experience is that I'll move the code around to suit depending on what
I'm doing.


> Also keep in mind, that 
> one of my design principles is that XOM by its nature should help 
> inexperienced developers do the right thing and keep them from doing 
> the wrong thing. 

Yes. On the other hand, experienced developers may grow tired of an API
that does too much handholding or is verbose through use. My inclination
would be to target capable Java/XML developers and lift the rest up by
other means ("Effective XOM")


> The learning curve needs to be really shallow, and 
> that includes not relying on best practices that are known in the 
> community but are not obvious at first glance.

I think the problem you'll have is leveraging Java developers away from
JDOM and DOM. JDOM is going through the JCP and the DOM ships with the
JDK. So long as the API isn't littered with calls, it'll be easy enough
to grasp (my favourite Java API is Javaspaces, which is effectively one
class).

Bill de hÓra 
--
Propylon
www.propylon.com 

 



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.