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?

Recommended Answers

All 2 Replies

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.

"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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.