• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What do i choose???

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Suppose i want to store 2 attributes
say,name and age of a person ,do i go for an XML document or a properties file?Depending on what do I choose?
Thanks
Marilyn
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marilyn,
I find XML very cool and hot. But in your case I think and XML document would be an overkill. A property file would be more than fine.
Cheers
Ambrose Tati
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Ambrose - unless you mean you'll store the name and age of more than one person. Then, there's no obvious logical way to organize the data in a properties file - but it's easy in XML.
 
Marilyn Monickam
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks Ambrose and Jim.
Let us consider another case where i have to store the information of a 100 people .In that case why do you think an XML file would be a better choice?
I am new to XML
Marilyn

 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, a property file requires you to have a unique name for everything, and allows you to map each name to a unique element. I suppose that if you wanted to just store name and age, you could use a property file:

But already there are several problems. The names must be unique. They can't have spaces in them, so I replaced spaces with underscores. And most importantly, what if I want to store another bit of data, like date of birth? Where do I put it? The properties file is a lousy way to manage this much data. But it's easy with XML:

Or if you prefer:


[This message has been edited by Jim Yingst (edited July 13, 2001).]
 
Marilyn Monickam
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim ,

I understand that the properties file is a lousy way of storing very large data since you need a unique name for each attribute you store
okay forget a property file and consider a simple text file
What if i get the data stored like this?
name =Joe Smith
age =24
birthdate=9/12/76
name=Bill Evans
age=27
birthdate=10/30/79
name=Sara Miller
age =26
birthdate=4/12/77
and then introduce some parsing logic to retrieve data?
are there any more advantages of XML apart from readability?
Marilyn
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, you invent your own format and parse the data using a home-grown parser. What happens when you want to send this data to a third-party client? Since this is a nonstandard format, you will also have to send them the parser, the document structure and all the other repertoire in order for them to make sense out of this data. What happens if you change the format, say after one year? See where I'm going?
If you use XML instead of the flat file, you can be rest assured that everyone else who is XML-aware can readily accept and process your file.
Having said that, I can tell you a number of drawbacks with the text format that you are using. For example, it is quite hard to represent hierarchically organized data. Even harder to represent relations between them. If you decide to find your way around these limitations, you may on your way trying to reinvent the XML


------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Marilyn Monickam
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ajit

I am convinced now.
Thanks
Marilyn
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two more important advantages of using XML here: 1) A lot of the work has already been done for you - e.g. rather than writing the parsing code yourself from scratch, you can take advantage of existing parsing modules, and customize them to your needs. 2) XML is relatively hot and trendy right now, so in terms of your personal marketability in IT, it can't hurt to have some XML experience on your resume.
 
reply
    Bookmark Topic Watch Topic
  • New Topic