[Seaside] Lists and ownership

Brian Brown rbb at techgame.net
Mon Nov 1 19:28:55 CET 2004


Quoting Jim Menard <jimm at io.com>:

> I have a list of things (an address book), and I'm writing a simple Seaside 
> app to display the list and CRUD entries. I have a bunch of basic, related 
> design questions. Any help will be greatly appreciated. There are a lot of 
> questions here; answers like "go read XXX" would be just as helpful as direct
> 
> answers. I have read the few Seaside tutorials and docs I've been able to
> find.
> 
> Who should "own" the list of entries? Should I create the list as a class 
> instance variable of the entry class, or as a global entry in Smalltalk?
> 

A pattern I have used in the past is to create a class the represents my data,
like the Entries class you mention. I'll put a class side variable that will
hold the data, and make accessor methods to get at the data:

Entries list do: [blah...]

then in my Seaside session, I would create an accessor that hides that:

MySession>>entries
   ^ Entries list


so in the rest of the app you are doing things like:

self session entries add: anEntry


Later, you can switch to using a GOODS database or some other db to store your
entries, and as long as you protocal for adding and deleting entries doesn't
change, your web app won't have to change a whole lot.

For example, if you have:

Entries>>addEntry: anEntry

Entries>>deleteEntry: anEntry

you can hide whether it's implemented as a simple Collection or as something else.


Brian

-- 
Brian Brown
TechGame Networks, LLC.
http://www.techgame.net


More information about the Seaside mailing list