[Seaside-dev] basicNew

Julian Fitzell jfitzell at gmail.com
Tue Oct 7 00:43:46 UTC 2008


On Sun, Oct 5, 2008 at 7:38 PM, Avi Bryant <avi at dabbledb.com> wrote:
> On Sun, Oct 5, 2008 at 3:12 AM, Julian Fitzell <jfitzell at gmail.com> wrote:
>
>> WAPoint class>>x: xNumber y: yNumber
>>  ^ self basicNew initializeWithX: xNumber y: yNumber; yourself
>>
>> WAPoint>>initializeWithX: xNumber y: yNumber
>>  self initialize.
>>  x := xNumber.
>>  y := yNumber.
>>
>> If you really want #new to work and there are reasonable defaults, then add:
>>
>> WAPoint class>>new
>>  ^ self x: 0 y: 0
>>
>> Is there a problem with this approach that I'm missing?
>
> I think it's equivalent, and probably more Smalltalk-y.  So, the
> convention becomes:
>
> - each class has exactly one initialization method on the instance side
> - if that initialization method has the same selector as its
> superclass' initializer, it should call super.  Otherwise, it should
> call its (inherited) superclass initializer, as you do in that
> example.
> - on the class side, you should have one designated constructor method
> that uses #basicNew and then the designated initializer.  You only
> need to reimplement this when you change the designated initializer.
> - you may also have alternate constructors that simply call the
> designated constructor with different parameters
> - if you are changing  the designated initializer/constructor, you
> must override your superclass' designated constructor to do something
> appropriate (either call the designated constructor with suitable
> defaults, or error if there are no defaults to use)
>
> Julian, having gotten here, it's feeling awfully familiar - I'm pretty
> sure the original conventions for Seaside code came about from exactly
> the same discussion years ago, and then got lost...

Yup, I'm sure you're right.

So, assuming there are no further dissenting opinions (are there
any?), someone should update the developer documentation.

And who wants to write the code critic rules? :)

Julian


More information about the seaside-dev mailing list