Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XML vs Properties file  RSS feed

 
Suresh Sankar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
which one is good(in performance).for dynamic configuration of application
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming the config information doesn't change during the runtime of the application, performance should not be a major factor in deciding between the two. It's likely that startup and configuration time pale in comparison to the overall execution time of the application.
 
Suresh Sankar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean which one is advanced and flexible
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would only go with a properties approach IF:
1. All parameters can be represented as simple name - value pairs
2. There is absolutely no hierarchy or other structure that controls the use of the name - value pairs.

Dynamic configuration (which I take to mean changing the configuration of a running program) can be done with either approach. Just make sure that synchronization is used to prevent access during the changeover, and that changes properly propagate through the system.

I use XML where my applications have to support a fairly deep hierarchy and properties for simple stuff.
Bill
[ July 05, 2005: Message edited by: William Brogden ]
 
S Hussain
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well... heirarchy in XML is imposed by the user... this can be done similarly in properties file.
For instance, in XML
<main>
<sub1>
<sub11/>
<sub12/>
</sub1>
</sub2>
</main>

Can be written as
main.sub1.sub11=
main.sub1.sub12=
main.sub2 =

My point is that XML structure/heirarchy can be imposed on properties file.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We used to see a lot of properties files like that in JRun servlet configuration before the servlet API added web.xml
they were a real pain to track, write and edit.
By going to XML you can use the XSLT, Xquery, Xpath, namespaces, entities, DTDs and Schema.
Nothing similar exists for properties.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!