[Interval Problem] 2 cents

Alan Lovejoy sourcery at pacbell.net
Mon Aug 2 22:12:27 UTC 1999


> ** Original Sender: "Jarvis, Robert P." <Jarvisb at timken.com>
>
> Well, <grumble-snarl>, I was *about* to make the point that it's easier to
> search for method references than for variable references, except that I
> just figured out how to do the latter easily (there's an instructive lesson
> here about how one (well, *this* one, anyways :-) gets into certain patterns
> of though and action, and other thoughts and actions become unthinkable and
> undoable, but I digress...) and so it looks like that portion of my argument
> just came off the track.  Interesting that you mention "Smalltalk Best
> Practice Patterns".  I seem to recall that Kent actually switch-hit on this
> issue, coming out both in favor of and against accessors/direct access.  I
> think his final call on it was "horses for courses", and I forget what the
> guidelines were (book's at home, I'm not).

But the whole point of my position is precisely that the "always use accessors"
rule is too simplistic, not that it's never a good idea.  It often is a very good
idea, which is why Kent "switch hits" on the issue.

> As far as "maintainability" goes, say that you have to modify your actions
> upon "setting" a value to include a whole bunch of extraneous crud.  For
> example, let's say you've got a simple accessor that sets the desired
> shipping date for an order.  Later the users come along and say, "Oh by the
> way, if you're setting the shipping date and the customer's desired receipt
> dates haven't been set, go ahead and set those to some default values,
> there's a good lad, off you go...".  If you've directly accessed the
> "shipping date" variable directly you'll now have to go back and either A)
> change the code (in potentially many places) so it sets the other variables
> as well, depending on some conditional logic, or B) write and retrofit an
> accessor that'll do this for you.  I'll grant you that you can always do
> (B), but if you've written and used the accessor from the beginning IMHO
> you're much better off.

Ah, but you appear to be referring to mutators, n'est-ce pas?  If so, I have
already said I feel that the case for using mutators is much stronger.  (To
me, "accessors" refers to methods that are used to read variable values, 
and specifically not to methods that are used to assign values to variables).

--Alan





More information about the Squeak-dev mailing list