[squeak-dev] The Trunk: Environments-cmm.38.mcz

Chris Muller asqueaker at gmail.com
Mon Dec 23 18:01:28 UTC 2013


> On Sun, Dec 22, 2013 at 12:43 PM, Chris Muller <asqueaker at gmail.com> wrote:
>>
>> So here is another correct example of CPM when more than one variable
>> needs initialized.
>>
>> Your home-brew version of CPM does the same thing,
>
>
> If you need a name for it, let's call it the "Single Initializer" pattern.

Why, it has the same number of "initializers" as CPM.  #initialize
(for default values) and #initializeWith:... for constructor
parameters.

>>
>> but it 1) violates
>>
>> the rule to say things once and only once,
>
> Huh? You keep saying this, but there's no duplication that I can see in the
> methods you removed. Could you point it out more explicitly?

You have "self initialize" in all of your #initializeWith:... because
you chose to call #basicNew instead of #new.  It's a throwback to
2002.

 >> 2) has #initialize getting
>> called from any of half-a-dozen places rather than the ONE place
>
> So? Sending a single message in more than one place is fine. It's what
> messages are for.

When you're duplicating the same code over and over again ("self
initialize") in all your subclasses, that should be a clue that you
should inherit that behavior from the superclass instead of repeating
yourself.

That's the standard followed by the rest of the image.

>> 3)
>> doesn't factor the behavior of simply *constructing* a _well-formed
>> object_ from the behavior of fully initializing it (i.e.., building up
>> a large cache).
>
> What are you talking about? None of the classes you've "cleaned up" has a
> cache.

The CPM pattern covers general case, not just your classes.

> I think maybe some of your confusion comes from the fact that all these
> classes inherit from Object. That's a degenerate case, and the description
> of Single Initializer that I posted considers the more general case of a
> class hierarchy. I've attached a very simple example that might help clarify
> things.

I'm not confused at all.  And, I think you and Frank implying I was
(while you clearly demonstrated YOU were) from the get-go of this
discussion was the genesis the "adversarial" nature of this
discussion.  You and I always seem to fall into that trap -- we should
find a way to avoid it so we can be more productive in the future.

> It might help to think of it this way: the fundamental principal is that
> every instance variable gets initialized exactly once. Since the variables
> in a given instance may be declared in different class in the hierarchy,
> each class provides an initialization method for the instance variables it
> declares.

Right, of course.  As opposed to what?  You're saying something above
which everyone already agrees on, and making it sound like CPM doesn't
do that or... what, I don't know.

Let's move on because I have more important, _design-level_ criticisms
of Environments to discuss.


More information about the Squeak-dev mailing list