0

I just have a quick question. I am working on a program for a friend of mine, more specifically a program that keeps track of stats of characters makes rolls etc. for DnD. Anyway, I am going to save the data using Serialization and keep the data together via a parent class ArrayList. Since I am going to make this a GUI based program with multiple windows running in tangent (one for each character), what would be a good approach to keeping track of and saving all of the separate data. I was thinking of something like making a global(and by that i mean a 'global class') ArrayList, so the entire program could use the same arraylist. Is there a better approach?

Edited by pinsickle: To confirm that I am aware that Java lacks global variables

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by JamesCherrill
0

You would be better off using a "DB" approach. Even if it is a "homegrown" type thing using RandomAccessFile, but better would be something like JavaDB/Derby.

0

"Global" data structures updated at random by multiple processes is generally a formula for disaster. Much better to create a proper class for data persistence with public methods that the GUI can call to submit data. Define the signatures of those public methods very carefully, then look at how best to implement them (serialisation, Derby etc). If necessary you will be able to swap out an initial simple version for a proper final implementaton without changing the public method signatures, and therefore not affecting the GUI at all.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.