Miscellaneous questions...

stéphane ducasse ducasse at iam.unibe.ch
Fri Sep 9 19:05:58 UTC 2005


Basically you use basicNew when you change new to raise an error.

Now to reuse possible initialization code of the super without  
duplication
is is better to move that code as instance methods

Instead of
A class>>new

     super new
         setBla; setFoo; set Zork

B class>>new
     self error

B class>>specialNew
     self basicNew setBla; setFoo; set Zork

do

A class>>new

     super new
         blaFooZork

A>>blaFooZork
     self setBla; setFoo; set Zork

B class>>new
     self error

B class>>specialNew
     self basicNew blaFooZork

By the way new since 3.7 invokes automatically initialize.

Stef






On 9 sept. 05, at 19:58, Ramon Leon wrote:

>>
>> why don't you publish it on squeaksource and squeakmap.
>> I looked at the code and it sounds good.
>>
>
> I'm not comfortable with that yet, especially since it's not fully
> functional yet, and got put on the back burner for more pressing  
> things.
> It's going to be an Ajax style Seaside app, but mostly it was to force
> me to learn Seaside, but maybe when I finish it, I'll publish it.
>
>
>>> !TPHand class methodsFor: 'instance creation' stamp: 'RJL 7/3/2005
>>> 14:09'!
>>> newGame: aGame
>>>     ^self basicNew
>>>         initialize;
>>>         game: aGame;
>>>         yourself.! !
>>>
>>>
>>
>> I would write
>>
>>
>>>
>>> !TPHand class methodsFor: 'instance creation' stamp: 'RJL 7/3/2005
>>> 14:09'!
>>> newGame: aGame
>>>     ^self new
>>>         game: aGame;
>>>         yourself.! !
>>>
>>
>> stef
>>
>
> I was wondering about that, I don't recall exactly where I picked up
> that habit, but I recall reading somewhere about using basicNew  
> instead
> of new, though I don't recall why.  If that's wrong, thanks, excellent
> tip, I was tired of typing initialize all the time anyway.
>
>
>




More information about the Squeak-dev mailing list