<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 23, 2013 at 1:01 PM, Chris Muller <span dir="ltr">&lt;<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>&gt;</span> wrote:<br>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
&gt;&gt; Your home-brew version of CPM does the same thing,<br>
&gt;<br>
&gt;<br>
&gt; If you need a name for it, let&#39;s call it the &quot;Single Initializer&quot; pattern.<br>
<br>
</div>Why, it has the same number of &quot;initializers&quot; as CPM.  #initialize<br>
(for default values) and #initializeWith:... for constructor<br>
parameters.</blockquote><div><br></div><div>Because I find &quot;your home-brew version of CPM&quot; insulting. &quot;Single Initializer&quot; conveys the intent of the pattern pretty well, I think.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><span style="color:rgb(34,34,34)">You have &quot;self initialize&quot; in all of your #initializeWith:... because</span><br></div>
you chose to call #basicNew instead of #new.  It&#39;s a throwback to<br>
2002.</blockquote><div><br></div><div>Ah. Well, I&#39;m not bothered by a single message send appearing in more than one place. </div><div><br></div><div>Think of #new as a 0-parameter constructor. It sends #basicNew to get an instance, then sends #initialize to initialize its state.</div>

<div><br></div><div>Now consider the #prefix: constructor that you changed in <span style="font-family:arial,sans-serif;font-size:13.333333969116211px">AddPrefixNamePolicy. It&#39;s a 1-parameter constructor, which follows exactly the same pattern as #new, extended to take a parameter: it creates an instance with #basicNew, then sends #initializeWithPrefix: to set up the instance&#39;s state. </span><span style="font-family:arial,sans-serif">EnvironmentInfo class&gt;&gt;name:organization:packages: also follows the pattern. It accepts 3 parameters, creates an instance with #basicNew and passes the parameters to the initializer. </span></div>
</div></div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Because Smalltalk has keyword messages, we can&#39;t include general parameterized constructors in the base image, because they wouldn&#39;t have descriptive names. They&#39;d be called something like #newWith: and #newWith:with:with:. It&#39;s better to let people define their own constructors. </div>
<div><br></div><div>That gives me an idea, though. Instead of #prefix: and #<font face="arial, sans-serif">name:organization:packages:, these constructors should be called #newWithPrefix: and #newWithName:organization:packages:. That would be clearer because it mirrors the structure of the initialization messages. </font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">See, this debate is useful after all. </font></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>

 &gt;&gt; 2) has #initialize getting<br>
&gt;&gt; called from any of half-a-dozen places rather than the ONE place<br>
&gt;<br>
&gt; So? Sending a single message in more than one place is fine. It&#39;s what<br>
&gt; messages are for.<br>
<br>
</div>When you&#39;re duplicating the same code over and over again (&quot;self<br>
initialize&quot;) in all your subclasses, that should be a clue that you<br>
should inherit that behavior from the superclass instead of repeating<br>
yourself.<br>
<br>
That&#39;s the standard followed by the rest of the image.</blockquote><div><br></div><div>It looks like this is the crux of our disagreement. My response above applies here too.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
&gt;&gt; 3)<br>
&gt;&gt; doesn&#39;t factor the behavior of simply *constructing* a _well-formed<br>
&gt;&gt; object_ from the behavior of fully initializing it (i.e.., building up<br>
&gt;&gt; a large cache).<br>
&gt;<br>
&gt; What are you talking about? None of the classes you&#39;ve &quot;cleaned up&quot; has a<br>
&gt; cache.<br>
<br>
</div>The CPM pattern covers general case, not just your classes.</blockquote><div><br></div><div>Ok, then what makes you think that Single Initializer can&#39;t deal with caches well? If you have a case where you need to populate a cache separately from initializing the object to *have* a cache, well, then write your initializer that way. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Let&#39;s move on because I have more important, _design-level_ criticisms<br>
</div>
of Environments to discuss.<br></blockquote><div><br></div><div>Sure, criticize away, I&#39;m happy to discuss. But as long as you&#39;re committing your &quot;clean ups&quot; to the trunk, I don&#39;t want to just drop this. </div>
</div><br></div><div class="gmail_extra">Colin</div></div>