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

Dario Trussardi dario.trussardi at tiscali.it
Fri Nov 15 09:46:37 PST 2013


Ciao,

> Hi guys,
> 
> First, let me say that I was really hoping that the User Guide has a chapter for what I will ask in this thread.
> 
> Ok, I understood basic concepts of GemStone. I understood it's basic classes and libraries. I understood the basic transactions concepts. I could even run my webapp from inside GemStone. Cool. But now... how do I persist for real in GemStone? How do I design my app API for storing, retrieving, editing, removing objects?
> 
> As far as I understand (please correct me if I am wrong), the first thing to know is that we should put our persistent objects somehow reachable from the user smalltalk dictionaries. Ok, as most OO DBs, GemStone works by reachability. 
> 
> Second. Since the classes of my app are in those smalltalk dictionaries, and class variables are reachable from my classes, then whatever I store in class variables are persistent, right? (of course, unless I store there some objects that cannot be persisted).
> 
> Third...I would try not to enter too much in the transactions problem right now. I would like to keep using the GLASS as it comes for the moment...
> 
> So...Ideas:
> 
> 1) I keep a collection in a class side for each of my classes whose instances I want to persist. And I implement a protocol add:  remove:  etc that I put in Behavior. Them from my code I do: "Client addObject: anInstance"
> 
> 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 my GLASS system i create a ApplicationSystem class with some instance variables to manage the data i need for one specific application problem

	name		Name of the environment
	rfrDb		Dictionary for specific DataBase instance  ( Costumer - Items ......   any with a specific dictionary of the relative keys)
	rfr.....
	rfrGlobal 	for global data relative to the specific Application 

After  i define UserGlobals instances with the name of the specific environment.

	EnvironmentA	->   anApplicationSystem  

	EnvironmentB	->	anApplicationSystem

I create a WASession subclass DTRWASession with a 'applicationSystem' instance variable.

When i open a new web session i understand from the pathString request the relative environment name  ( EnvironmentA or Environment...... )

	and then i set the aDTRWASession applicationSystem instance to the specific anApplicationSystem.

A this time my superclass DTRDataBase ( superclass of all my database definitions )

	in the methods intercept the session with the code:

			| session |
			session :=  WACurrentRequestContext value session.
	
	and return the specific dictionary

		^ session applicationSystem rfrDbFor: className  ( Costumer - Items ......   )

Or a specific other request for example :

		^ session applicationSystem rfrGlobalFor:  anSymbol. 


Can you understand  the explanation of my solution?

	Dario

> 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. 
>  
> 
> Thanks!
> 
> -- 
> Mariano
> http://marianopeck.wordpress.com
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20131115/12476dc3/attachment.html>


More information about the Glass mailing list