Author | Message |
---|---|
dbravoru
Posts: 60
|
Posted 21:43 Oct 13, 2014 |
I am having trouble figuring out what exactly Persister<T> is. I've attempted to create an interface Persister<T> with methods with the intent of saving an object, retrieving an object, saving a list of that object, and retrieving a list of that object. However, i do not understand how the program is supposed to retain saved objects and lists even after you close the program. Also, the example in Lecture 3, Monster Persister, not saved as an interface, which leads me to believe I shouldn't make Persister<T> into an interface. Last edited by dbravoru at
22:14 Oct 13, 2014.
|
kknaur
Posts: 540
|
Posted 22:11 Oct 13, 2014 |
I read over John's lab and I think I know what he wants. The reason your objects will "persist" even when the program is finished is because your Persister class should use Object I/O (reading and writing entire object data from / to a separate (external) file.). Let's for example call our external file savedData.dat. (Here the extension doesn't really matter, you could use a .txt, .dat, .bin, really almost any extension.) When your program exits, that file will still exist with all of the information that you wrote to it. It would be the same concept if you were to save the information to a database. The database will still exist even if your program is not running. You are just substituting an external file for an actual database. As far as whether or not it should be an interface....ask John for some clarification on that because you could write it either way (as an interface, or just a separate class). Again he will need to provide clarification on that. |
dbravoru
Posts: 60
|
Posted 22:13 Oct 13, 2014 |
This really helped, thanks! @KKNAUR |