<div dir="ltr">I think that the issue is of readability vs. efficiency. If you are writing code that needs to be efficient (at the cost of readability and ease of maintenance), you could do something like this: (option #1)<br>
<br>WAPoint class&gt;&gt;x: xNumber y: yNumber<br>^self basicNew initializeWithX: xNumber y: yNumber<br><br>WAPoint&gt;&gt;initialize<br>&quot;make sure you also update #intializeWithX:y: if ever you modify this method&quot;<br>
super initialize.<br>x := 0.<br>y := 0.<br><br>WAPoint&gt;&gt;initializeWithX: xNumber y: yNumber<br>&quot;this is a copy of #initialize, but I directly set x and y to the values I want, because I&#39;m in a hurry here&quot;<br>
&quot;any modification of #initialize should be also done here&quot;<br>super initialize.<br>x := xNumber.<br>y := yNumber.<br><br>Note that I wouldn&#39;t try to link these methods. It&#39;s ugly code duplication, with the aim of speed.<br>
<br>If you didn&#39;t want extreme speed, but wanted rather readable code, I would recommend this: (option #2)<br><br>WAPoint class&gt;&gt;x: xNumber y: yNumber<br>^self new <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x: xNumber;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y: yNumber;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yourself<br><br>WAPoint&gt;&gt;#initialize<br>super initialize.<br>x := 0.<br>y := 0.<br><br>So doing it the clean (but maybe not optimal) way saves you one method and I think increases readability. You don&#39;t even need a comment to know what&#39;s happening.<br>
Whereas the first example (the fast one) introduces one extra method, whose name isn&#39;t really appealing, and it also introduces code duplication, more maintenance effort, and the reason for having #initializeWithX:y: implemented that way isn&#39;t clear, so you need a comment to explain it, because you deviated from the &quot;vanilla&quot; #initialize model.<br>
<br>I would say the standard is option #2. The exception is #1, if you want speed at the cost of other things.<br><br>My 2 cents,<br><br>Yann<br><br><div class="gmail_quote">On Mon, Sep 29, 2008 at 9:20 PM, Avi Bryant <span dir="ltr">&lt;<a href="mailto:avi@dabbledb.com">avi@dabbledb.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Mon, Sep 29, 2008 at 12:59 PM, Randal L. Schwartz<br>
&lt;<a href="mailto:merlyn@stonehenge.com">merlyn@stonehenge.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt; &quot;Avi&quot; == Avi Bryant &lt;<a href="mailto:avi@dabbledb.com">avi@dabbledb.com</a>&gt; writes:<br>
&gt;<br>
&gt; Avi&gt; Assuming no other changes to my code, this means that super&#39;s<br>
&gt; Avi&gt; initialize is not called when you use the #x:y: or #point: class side<br>
&gt; Avi&gt; creation methods, but *only* when you use a bare #new.<br>
&gt;<br>
&gt; Well, that&#39;s why you don&#39;t call basicNew unless you really mean it.<br>
&gt;<br>
&gt; The problem is that you need to decide if you&#39;re doing it the Squeak<br>
&gt; way or not.<br>
&gt;<br>
&gt; What I described in my earlier post is the Squeak way, and the way<br>
&gt; I learned looking at the Smalltalk image in 1981. &nbsp;If you want to<br>
&gt; do it the Objective C way, be prepared for some incompatibility.<br>
<br>
</div>Ok, I&#39;m still looking for a *complete* example of the &quot;Squeak way&quot;,<br>
and none of your posts so far provide one, so let me set up a straw<br>
man and you can tell me where it&#39;s wrong.<br>
<br>
WAPoint class&gt;&gt;x: xNumber y: yNumber<br>
 &nbsp;^ self new x: aNumber y: aNumber<br>
<br>
WAPoint&gt;&gt;x: aNumber y: yNumber<br>
 &nbsp; x := aNumber.<br>
 &nbsp; y := aNumber<br>
<br>
WAPoint&gt;&gt;initialize<br>
 &nbsp;super initialize.<br>
 &nbsp;self x: 0 y: 0<br>
<br>
The only interesting/contentious part of this, I think, is the very<br>
last line, where #x:y: is sent from the overridden #initialize method.<br>
&nbsp;I believe you have to include it, because if you don&#39;t, then sending<br>
&quot;WAPoint new&quot; ends up with an uninitialized instance (nil for x and<br>
y). &nbsp;If you do include it, however, you end up performing the<br>
initialization twice - this is not a big deal when all you&#39;re doing is<br>
assigning some instance variables, but you can certainly imagine cases<br>
where doubly initializing an instance would be costly or incorrect.<br>
That&#39;s why I don&#39;t like this approach, but if I&#39;ve misunderstood it,<br>
let me know.<br>
<br>
Here&#39;s the alternative I&#39;m proposing again, for reference:<br>
<br>
WAPoint class&gt;&gt;x: xNumber y: yNumber<br>
 &nbsp;^ self basicNew x: aNumber y: aNumber<br>
<br>
WAPoint&gt;&gt;x: aNumber y: yNumber<br>
 &nbsp; super initialize.<br>
 &nbsp; x := aNumber.<br>
 &nbsp; y := aNumber<br>
<br>
WAPoint&gt;&gt;initialize<br>
 &nbsp;self x: 0 y: 0<br>
<br>
This way, whether you use #x:y: or #new, you end up initializing the<br>
instance exactly once - and I&#39;m still unclear on what the concrete<br>
disadvantages are.<br>
<font color="#888888"><br>
Avi<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
seaside-dev mailing list<br>
<a href="mailto:seaside-dev@lists.squeakfoundation.org">seaside-dev@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev</a><br>
</div></div></blockquote></div><br></div>