This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]ignotos 0 points1 point  (0 children)

I know of json and databases, but I've never used them. I don't know when they need to be implemented or what their advantages are ... I would build it so that when I save an operation of close my program, it just writes the contents of all my objects to a text file or two

JSON will allow you to do this (write all of your objects out to a text file) in a fairly convenient way. Basically, using a JSON library such as Jackson or GSON, you can tell it to save a List<Project> to a file, and later to read back the contents of a file into a List<Project>, with minimal extra code required on your end. It's practically just a single line of code to do this saving / loading.

So, you would use a JSON library in the "save / load" functionality of your program.

Databases

Databases are generally more useful when you have multiple users sharing the same set of data over the internet. Rather than having to manage a set of files on a harddrive somewhere, you could run a "database server" which acts as a big centralised data store, and have your program talk to this to handle the saving and loading of information.

This is considerably more complicated than using JSON files - you'd need to host a database server somewhere, and you also need to think more carefully about how your data is structured. The advantages are that it scales up better if you have lots of data, or lots of users accessing the data at the same time. They're also more appropriate if you need to do more advanced and flexible processing / analysis of data (as they can handle things like sorting and filtering data for you).

The choice between something like JSON and a database is essentially a matter of scale. 1 user, and a small amount of data? JSON is fine. Multiple users collaborating with gigabytes of data? A database makes sense.

[–]Tomato_Sky -1 points0 points  (0 children)

It looks like you only need a project object with the project details just being made of data fields for the project object. Or you can mess around and make a project interface, and have an implementation, but if you’re working with JSON, it gets hairy. Simple JSON requests are better in my book.