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

Chris Muller ma.chris.m at gmail.com
Mon Dec 23 23:25:32 UTC 2013


> 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.

But I'm sounding like a broken record so... later.  :)


More information about the Squeak-dev mailing list