OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] InnerXml is like printf (WAS: Underwhelmed)

[ Lists Home | Date Index | Thread Index ]

Miles Sabin <miles@milessabin.com> wrote:

| But on reflection (and playing devils advocate a bit) maybe it's not as 
| unreasonable as it seems. It has quite a lot in common with printf- 
| style IO APIs, which despite being error-prone (and occasionally the 
| source of security vulnerabilities) have proved to be surprisingly 
| resistant to replacement by more structured, typesafe or object- 
| oriented APIs.

Because it's

  1.  Quick
  2.  Dirty
  3.  Easily assimilated as rote technique by the grunt programmer

So, you get yourself a roomful of GPs and have 'em crank printfs until the
budget runs out.  It's called Resource Management, I believe.

| Why do these string-template approaches support such dramatically more 
| compact and readable code? I think it's simply because the syntax of 
| the template-strings provides a domain-specific "little language" which 
| is better tuned to the task at hand than the generic mechanisms 
| provided by the host language. 

Or libraries designed with the GP in mind.

| How about something XPath-like? For example,
| 
|   String s = "XPath expansion";
|   int i = 2;
|   parent.appendChild("usability[@factor="+i+"]/text("+s+")");
| 
| or if we waited for J2SE 1.5 which'll have auto-boxing and concise array 
| literals, we could even have,
| 
|   parent.appendChild("usability[@factor=%i]/text(%s)", {i, s});

How about

   import some.library.ConvenienceFunctions ;

   String s = "The Right Library" ;
   int    i = 2 ; 

   parent.add( new Eusability( ).aFactor( 2 ).add( s ) ) ;





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS