[Glass] Design API for adding/removing/editing objects in GemStone

Johan Brichau johan at yesplan.be
Fri Nov 15 11:45:26 PST 2013


On 15 Nov 2013, at 18:51, Dale K. Henrichs <dale.henrichs at gemtalksystems.com> wrote:

> 2) I have one "MyAppRepository" class which is a singleton. The unique instance has a dictionary. From my code I do "MyAppRepository current addObject: anInstance".
> And MyAppRepository instance has a dict and operates for that dict (asking #class to the receiver and put that as keys...).
> In GemStone I would avoid direct references to classes as much as possible (use names and a lookup instead). Classes in GemStone are versioned so it is very possible (and likely) that you will have multiple instances of a class floating around so it is not a good idea to hang onto them ...

+1 (read: got bitten by this in the past :-)
This is a rule we apply: never hold on to classes as values in persistent objects. Instead, as Dale says, store the name and do a lookup when you need the class.
If you hold on to a class, you must change the reference to the new class version manually when you upgrade the code. 

> 3) others...
> 
> So, what do you do? My idea was to use 2) but reuse the repository class of Voyage and reuse also its protocol. 

We store a dictionary that is our 'persistent root' in UserGlobals:
UserGlobals at: #MyDatabaseRoot put: (self createDatabaseDictionary)

Johan


More information about the Glass mailing list