1

I'm looking at developing a simple application in Java for a game which allows a user to keep track of which items they own and how much experience they have obtained while using the item. All of this data is input by the user.

What is the idiomatic/standard way to persist the data that is being manipulated (the model)? The immediate possibilities seem to be saving it to a file, serialization, databases, etc, but many of these seem to be overkill for simple text fields that don't seem to necessitate objects. What is the idiomatic/traditional way to handle something like this?

sea-rob
6,9111 gold badge26 silver badges48 bronze badges
asked Mar 22, 2014 at 5:46
5
  • Are you asking about how to model the data or how to persist the data? Two completely different things. Commented Mar 22, 2014 at 7:02
  • Probably more of the latter, but I'm not sure I fully understand what it is that I'm actually going to need to address, so that's surely part of it. It does sound like a database would be a valid way of handling this and would allow me to focus on my code instead of focusing on the file handling. Commented Mar 22, 2014 at 14:22
  • Please, read what "model" and "modeling" means: en.wikipedia.org/wiki/Data_modeling It has nothing to with picking database or files, but how you structure the data to represent your problem domain. Also, the whole database vs. file vs. serialization is completely useless debate, because everyone will tell you to use databse. Commented Mar 22, 2014 at 15:30
  • Excellent, that's a perfectly valid answer, as I wasn't sure if this was a good place to use a database or if it would be overkill. Thanks for the clarification and answer :] Commented Mar 22, 2014 at 17:53
  • note: edited to replace "model" with "persist" (context to the comments above) Commented Mar 23, 2014 at 20:36

1 Answer 1

2

SQLite is a nice, lightweight database application. Some of the NoSql databases are easy to download and get running quickly, with low learning curve. I've heard Redis is pretty easy for saving simple data. MongoDB is very accessible as well, if you just use the basic features and don't worry about the complicated bits.

Managing everything in flat files on disk would work, too, but my guess is that the time it would take to define file formats, serialization, random access, and all the tricky parts -- with all the unit tests because you don't want a bug to corrupt your data -- then it would take more time and effort than just launching and learning something easy like SQLite or Redis.

answered Mar 22, 2014 at 6:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.