Saving and loading objects that reference of objects?
Posted: Mon Aug 24, 2015 3:36 pm
Hi there again,
I was wondering whether there was a way to save instances of objects that include instances of other objects.
For instance, I might have a family object that contains a slot for children and have multiple instances of person in the children slot, who might themselves have children and so on... Or I might have a bunch of information that I want to store in years, so that I can ask for the information concerning Scotland in 2005 by going something like: (population (get-me 'scotland (countries 2005)))
Stuff like that seems like it might be useful to be able to do. Though, I'm not sure whether it's typical to do that or whether people try to cram all the information into one master object so they only have to write one method to read the thing.
I'd know how to do it if it was just recurring down and across a list, but I don't know how to generate a representation of the object version of the same structure which can be saved out and loaded easily, (nor how to make the whole lot output to the screen in a sensible manner. Which, while it doesn't seem like it should be strictly necessary, seems likely to be entailed.)
At the moment I'm writing output methods for each class and trying to use those as needed, but it's a mess. Is there an easier way?
Thanks for reading
I was wondering whether there was a way to save instances of objects that include instances of other objects.
For instance, I might have a family object that contains a slot for children and have multiple instances of person in the children slot, who might themselves have children and so on... Or I might have a bunch of information that I want to store in years, so that I can ask for the information concerning Scotland in 2005 by going something like: (population (get-me 'scotland (countries 2005)))
Stuff like that seems like it might be useful to be able to do. Though, I'm not sure whether it's typical to do that or whether people try to cram all the information into one master object so they only have to write one method to read the thing.
I'd know how to do it if it was just recurring down and across a list, but I don't know how to generate a representation of the object version of the same structure which can be saved out and loaded easily, (nor how to make the whole lot output to the screen in a sensible manner. Which, while it doesn't seem like it should be strictly necessary, seems likely to be entailed.)
At the moment I'm writing output methods for each class and trying to use those as needed, but it's a mess. Is there an easier way?
Thanks for reading
