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: 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? Best, Marcel |
Hi Marcel,
could you maybe share some more details about this particular design goal of Newspeak? :-)
At the first glance, I do not really see the advantages of moving more and more "global getters" to Object. It: - inflates the Object protocol even more - might imply that there is some connection between the receiver and the project, or at least hide the global state (which one also could call "code perfuming" :-)) - and I don't see how it could help to replace the global object at all - you still need to wrap relevant calls with #becomeActiveDuring:, or speaking more in general about the proposed idiom, you would still need something like method wrappers unless you only want to override #currentThing for a single instance.
So what possible advantages am I missing right now? :)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Dienstag, 2. März 2021 10:03:02 An: squeak-dev Betreff: [squeak-dev] What about "self currentProject"?
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:
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?
Best,
Marcel
Carpe Squeak!
|
Class references are global references. The piece "self currentProject" does not reveal where it is coming from. It is a good thing to not expose global state to user code -- even if it is global at the moment. :-) Best, Marcel
|
In reply to this post by marcel.taeumel
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 |
Add my 2c to Dave's on this question. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do |
Thanks! :-) I like "Project world" (besides "Project uiManager") and I understand the strange connotation of "self currentProject" ... and maybe now understand why Christoph immediately thought about dynamically re-scoping the answer like "self currentWorld". Best, Marcel
|
Free forum by Nabble | Edit this page |