• Post Reply Bookmark Topic Watch Topic
  • New Topic

Acces to static data  RSS feed

 
Kim Mirtens
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program frequently needs acces to static data, namely tables with numbers. A test version of the program uses comma separated text files that look like this:

22270.300;4.000;8.875;10.584;77232.100;22.542;2.075
22864.200;4.100;8.786;10.539;77460.400;22.096;2.126
23458.800;4.200;8.695;10.494;77684.400;21.675;2.178
24053.900;4.300;8.602;10.448;77904.200;21.275;2.229
24649.600;4.400;8.507;10.402;78119.300;20.897;2.281

At start-up each row is loaded into a Record object with an instance variable for each column. These Record objects are then stored in an ArrayList of Record objects and when I need data I loop trough the list.

I now want to expand my program which would mean that my comma separated text files would get bigger and harder to maintain. I also think that the present approach isn't developers friendly because the data files are unreadable for anybody but me.

What would be the best approach for this problem? The two options I see are XML or using a Database. Is there a better way of doing something like this?
I prefer to use a local database because SQL seems much easier than learning XML parsers. The downside of a database would be data portability. I'm also worried that querying on the fly will be slower than accessing the data from the memory.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That example file is delimited by semicolons, not commas, but I guess the principle applies anyway.

What features do you want to gain, by changing format? For instance, a comment syntax?

Is the data really flat or hierarchical? If it is hierarchical, XML will make it easier to understand and to edit. If it is flat, XML will just make it more verbose, without much benefit.

Is the data really static? That is, does it really never change? Or do you mean it does not change during a single run of the program? Either way, a relational database sounds an over-the-top solution.
 
Kim Mirtens
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What features do you want to gain, by changing format? For instance, a comment syntax?


I want the data to be easily read by other people. It's an open source project and having data files with just numbers is not very accessible. This static data consists of stability information of a specific ship. To make my program portable to other ships I need it do be more structured and easier to understand. That way my program can be used for other ships when the stability information is structured in the same way.

Is the data really flat or hierarchical? If it is hierarchical, XML will make it easier to understand and to edit. If it is flat, XML will just make it more verbose, without much benefit.


It's just flat data.

Is the data really static? That is, does it really never change? Or do you mean it does not change during a single run of the program? Either way, a relational database sounds an over-the-top solution.


The data never changes.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!