[squeak-dev] 4.5 -- how should we proceed then?

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Dec 23 23:51:19 UTC 2013


2013/12/24 Chris Muller <ma.chris.m at gmail.com>

> > The reason I keep dissing them as setters is because they only set
> > _some_ state.
>
> My goodness Frank.  After all this you still are saying that?!  Please
> forgive me for correcting you one last time with emphasis.
>
> *** CPM's set ALL STATE required for a well-formed, functional object ***.
>
> That's also why I committed Environments-cmm.38 as a multi-variable
> example.
>
> Setters set one variable.  **Constructor Parameter Methods set ALL
> variables passed from a constructor**.  A Constructor is, by
> definition, a method capable of "constructing" a well-formed instance.
>
> > Now, granted, some like Point >> #setX:setY: happen to
> > fully initialize an instance, but the name does not make this
> > responsibility clear.
>
> The name makes clear *what it does*.  If it's #initializeWith: -- you
> better look at the method to know what it does besides set state..
> Plus, a constructor can't ONLY set state, it implies some sort of full
> "initialization".
>
> But, I'm repeating myself from 3 days ago..   :)
>
> > But (the nonexistent) Point >>
> > #initializeWithX:y: tells you loudly and clearly that the method
> > initialises the instance. That "#initializeWithX:y" is ugly to look at
> > and painful to type is just gravy: you shouldn't be calling that
> > method anyway.
>
> Not any more than you should call setX:y:.  Seriously, have you ever
> had the urge to call that?  I always check the protocol of methods I'm
> unsure about, and if it's correctly categorized, then you're relying
> on an ugly selector name, initializeWith: to "fix" something that
> isn't broken.
>
>
It's a bit late for changing that now, but it could as well be named
initializeX:x y:y to carry the exact intention.
Not every body knows that you should set once, more people know that you
should initialize once and only once.
So you could have just change With:, it would have been less controversial.

The other point being whether to invoke new or basicNew is more germane,
but not invoking new is a way to tell my instances are not created like
that. We could push it further and redefine new ^self error as you
suggested, but it's quite heavy...


> But I'm sounding like a broken record so... later.  :)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20131224/69862fff/attachment.htm


More information about the Squeak-dev mailing list