[Seaside] Re: Seaside & Ruby Rails Compared

goran at krampe.se goran at krampe.se
Thu Sep 8 09:01:03 CEST 2005

Hi folks!

=?ISO-8859-1?Q?G=FCnther_Schmidt?= <gue.schmidt at web.de> wrote:
> Avi,
> Avi Bryant wrote:
> > 
> > On Sep 7, 2005, at 4:56 PM, Günther Schmidt wrote:
> > 
> >> Goran,
> >>
> >> sorry, but I think that's bad practice.
> >>
> >> I suggest to use singletons that act as brokers instead.
> > 
> > 
> > What Göran was describing - having a class with a Default class var -  
> > sounds exactly like a singleton to me.  Is there some other pattern  you 
> > prefer?
> > 
> > Avi
> the class variable should hold the one single instance of the class, and 
> not anything else.

Which is exactly what I meant. This is btw conceptually the same thing
as having a global that is only available in the scope of the class,
subclasses and all instances/subinstances.

One could use a class instvar too - granted. Though people don't tend
to, not sure exactly if there are good reasons not to.

> The instance is the one that holds on to a list of objects of interest 
> (plus methods for adding and removing). I understood Göran's proposal to 
> use the class not for creating instances at all, but use it only to 
> provide slots for various data.

Eh, "only to provide slots for various data"? When did I say anything
like that?
Sure, I said "global state" instead of "singleton instance", perhaps
that triggered the misunderstanding.

So yes, it is almos the Singleton pattern, but not entirely - IIRC the
Singleton pattern states that it actively stops you from creating more
than one instance. I don't do that with SMSqueakMap for example, I just
keep track of a default instance that the tools can use when they are
"in doubt".

Almost everyone uses that default instance (when it comes to
SMSqueakMap) but there is/should be nothing stopping you from creating a
second separate instance and use that too, but then you will have to
"hold onto it" on your own.

regards, Göran

More information about the Seaside mailing list