[squeak-dev] What about "self currentProject"?

David T. Lewis lewis at mail.msen.com
Wed Mar 3 13:08:34 UTC 2021


On Tue, Mar 02, 2021 at 10:03:02AM +0100, Marcel Taeumel wrote:
> Hi all!
> 
> After typing "Project current" for the n-th time, I was wondering, whether "self currentProject" could be a nice little idiom for the Squeak environment.??
> 
> We had several thoughts on this matter:
> http://forum.world.st/Object-gt-gt-currentProjectWorld-td5044161.html#a5045072 [http://forum.world.st/Object-gt-gt-currentProjectWorld-td5044161.html#a5045072]
> 
> http://forum.world.st/Changeset-Eliminating-global-state-from-Morphic-tp5121690p5123334.html [http://forum.world.st/Changeset-Eliminating-global-state-from-Morphic-tp5121690p5123334.html]
> 
> 
> 1. Object >> #currentProject would be a *System extension in Object to not be dependent on Morphic.
> 2.?? "Project current world" could be replaced with "self currentProject world" (generic) or "self currentWorld" (specific to Morphic).
> 3. "Project uiManager" could be replaced with "self currentProject uiManager".
> 4. "Project current addDeferredUIMessage:" could be replaced with "self currentProject addDeferredUIMessage:".
> 
> So, we wouldn't have so many class references to "Project" in the code. It kind of reminds me about some of Newspeak's design goals. :-)
> 
> What do you think?
> 

I do not care for "self currentProject" because it suggests that each
object is responsible for knowing its currentProject. And it is not
going to save any keystrokes:

	'Project current' size ==> 15
	'self currentProject' size ==> 19

However, the "Project current world" idiom too wordy, and it is repeated
many times. An improvement for readability might be this:

  Project class>>world
      ^self current world

This would clean up a couple hundred repetitions of "Project current world" 
so that rather than "Project current world doOneCycle" we would say
"Project world doOneCycle".

It is the same as you have done for Project class>>uiManager and to me
it seems better for readability.

$0.02,

Dave



More information about the Squeak-dev mailing list