[Seaside] Storing WAComponent / WATask etc. in magma

Ramon Leon ramon.leon at allresnet.com
Tue Dec 23 16:07:31 UTC 2008


> e.g. in terms of a blog application: blog posts are stored in 
> magma in a collection. 

Fine so far.

> The master user has access to all posts but rather than
> having an instance variable which holds a collection of blog posts the
> user has an instance variable which holds a view on the blog posts to
> which this user has access. 

Not good.  You're creating a dependency in the model on the view, it should
be the other way around.  Models, i.e. your user, should not hold a
reference to the view that displays it, have the view hold a reference to
the model instead.  Your first instinct to have the user have a collection
of posts he has access to was more correct.

Try thinking like this... throw out the views altogether and just model your
domain all by itself.  Your objects are something like Blog, Post, User, and
Comment.  Get that all working first so you can grab a user in a workspace
and inspector and do stuff like "user posts" to see all the posts a user has
access to or "blog posts" to see all the posts in the blog, or maybe "blog
postsFor: user" to grab the posts a user can see.  Play around until you're
happy with the model and the persistence and have it all working without a
UI.

Don't start working on the views until you have the models all figured out.
The view is then nothing more than a layer that enables manipulation of the
persistent model.  Views are transient, not persistent, and should not be
stored.  Models should be unaware of the views that manipulate them.  Views
should have instance methods that represent the models they're manipulating.

> Thanks, Florian

Ramon Leon
http://onsmalltalk.com



More information about the seaside mailing list