Re: [Pharo-users] Simple OO smaltalk question
OOP in Smalltalk is nearly the same as in Java! No typecheck
I could do the same thing this way, right, but this seems more verbose and ugly then it has to be.
(user isKindOf: RSPerson ) ifTrue: [returnPage := (RSPerson firstPageForUserClass) ]. (user isKindOf: RSAdmin ) ifTrue: [returnPage := (RSAdmin firstPageForUserClass) ]. (user isKindOf: RSTeacher ) ifTrue: [returnPage := (RSTeacher firstPageForUserClass) ]. (user isKindOf: RSStudent ) ifTrue: [returnPage := (RSStudent firstPageForUserClass) ].
^returnPage
why don't you either declare a factory or simply define methods on the RS-Object
RSPerson >> firstPageForUserClass ^ cccc
RSAdmin >> firstPageForUserClass RSTeacher >> firstPageForUserClass
Stef
Why don't you just write user class firstPageForUserClass ? Lukas On 11 October 2010 09:16, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
OOP in Smalltalk is nearly the same as in Java!
No typecheck
I could do the same thing this way, right, but this seems more verbose and ugly then it has to be.
   (user isKindOf: RSPerson ) ifTrue: [returnPage := (RSPerson firstPageForUserClass) ].    (user isKindOf: RSAdmin ) ifTrue: [returnPage := (RSAdmin firstPageForUserClass) ].    (user isKindOf: RSTeacher ) ifTrue: [returnPage := (RSTeacher firstPageForUserClass) ].    (user isKindOf: RSStudent ) ifTrue: [returnPage := (RSStudent firstPageForUserClass) ].
   ^returnPage
why don't you either declare a factory or simply define methods on the RS-Object
RSPerson >> firstPageForUserClass     ^ cccc
RSAdmin >> firstPageForUserClass RSTeacher >> firstPageForUserClass
Stef _______________________________________________ Pharo-users mailing list Pharo-users@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
-- Lukas Renggli www.lukas-renggli.ch
participants (2)
-
Lukas Renggli -
Stéphane Ducasse