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
SmartRefStream
should help you. To quote from the documentation:Those wanting to finish the example in the book, follow these steps:
1. Go back in time and get a Pharo 1.4 from: https://gforge.inria.fr/frs/?group_id=1299
Scroll down and look for One-Click Pharo 1.4 and get the latest build, if there is a newer one than: https://gforge.inria.fr/frs/download.php/file/31359/Pharo-1.4-14457-OneClick.zip
Use the Configuration Browser to install Seaside and you're done.
1a. Or use the legacy development prebuilt Seaside, Scriptaculous, Magritte, Pier image running on Pharo 1.3 here: http://www.seaside.st/distributions/Seaside-3.0.7-final.zip
I got lucky using a Pharo VM from here: http://files.pharo.org/vm/pharo/20/mac/stable.zip
2. Get your code out of the current image via Monticello and then "back" into the older image. Success!
PS. More details here: FileDirectory and ReferenceStream Class equivalents in Pharo?