In Pharo Smalltalk I'm using ReferenceStream to serialise a list of objects -- here's the class definition of the objects I'm serialising:
Object subclass: #Task
instanceVariableNames: 'title notes list project dateNextAction dateCreated dateCompleted importance selected'
classVariableNames: 'Database'
poolDictionaries: ''
category: 'ToDo'
I'm using the SMFileDatabase
method described here:
http://book.seaside.st/book/advanced/persistency/image-based-persistency
This has been working well, and it's been nice not to have to use a database for my prototype app.
Howevere, here's the problem: when I add a new instance variable person
to Task
the load from ReferenceStream breaks:
Object subclass: #Task
instanceVariableNames: 'title notes list project person dateNextAction dateCreated dateCompleted importance selected'
classVariableNames: 'Database'
poolDictionaries: ''
category: 'ToDo'
It seems to not spot the new variable, and load the values into the wrong slots, so person takes the value of dateNextAction
, dateNextAction
takes dateCreated
and so on.
How can I stop this happening?
I've got it working by placing the new variable at the end of the list, but I'd like to group variables by type.
ReferenceStream is not supported anymore and has been deleted in Pharo 2.0. You should use Fuel which is well written, well documented, well tested and very fast. http://rmod.lille.inria.fr/web/pier/software/Fuel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With