[Seaside] Question for newbie

Claus Kick claus_kick at web.de
Fri Jan 9 16:59:02 UTC 2009

Steve Bleeke wrote:
> I read another question about a root class not showing on the configuration list for entry points even though it had a canBeRoot method.
> The answer was to place the canBeRoot method on the class side.  What does class side mean?

Everything in a Smalltalk system is an object.

Every object is an instance of a class.

The instance side defines behaviour for every object instance.

The class side provides general valid behavior, like whether a component 
canBeRoot for a Seaside application.

The common example is to have a Class Car, which has a class method 
#needsFuel which returns true.

It has an instance method called #move: which manipulates the tank 
filling of the car, decrement by moving, depending on whether an object 
of class Car needs fuel or not:

Car >> move: aDistance

self class needsFuel
fuel := fuel - aDistance //10.

Now, you create an instance of Car.

car := Car new.

car move: 100.

So the car has moved 100 somethings, which means the tank of that car 
has been depleted a bit.

Now you create a new instance of Car.

car2 := Car new.

car2 will still have a full tank.

Now, if you have a Class called "PerpetuumMobile", it is next to the 
Class Car, below the same parent called "Machine". This class answers 
false to #needsFuel, but has the same method #move:

PerpetuumMobile >> move: aDistance

self class needsFuel
fuel := fuel - aDistance //10.

So, moving an instance of PerpetuumMobile will not decrement the tank 

Of course, in reality, the move: method will be implemented in the class 

I hope this does make some sense to you.

Suggested readings: Object-Oriented Programming, Polymorphism, Inheritance.

More information about the seaside mailing list