[squeak-dev] Changeset: Eliminating global state from Morphic
Levente Uzonyi
leves at caesar.elte.hu
Sat Sep 12 19:29:11 UTC 2020
Hi Christoph,
Your description made me think that you created ProcessLocalVariables.
Instead you reimplemented their logic. Why?
Levente
On Sat, 12 Sep 2020, Thiede, Christoph wrote:
>
> Hi all,
>
>
> recent discussions have shown just another time that in spite of its overall modular and object-oriented design, the Morphic System still incorporates a number of global state variables that impede modular processes in some
> situations. For instance, running or even debugging any form of UI simulation code in a background process was likely to cause problems because, via the global state variables, two planned-to-be-independent
> projects undesirably shared their events, hands, and worlds. Concrete systems suffering from this global state include various UI tests executed using AutoTDD [1], or the screenshot generation framework for Squeak by Example
> [2] which I had the joy to co-develop.
>
>
> The attached changeset tackles these issues for all packages in the Trunk by wrapping the following three globals into process-local accessors: ActiveEvent, ActiveHand, and ActiveWorld.
>
> As the changeset contains patches of over 300 selectors in more than 100 classes every single line of which you probably will not feel like reading in detail, here is a summary of all changes I applied:
>
> * Added #activeEvent[:], #activeHand[:], and #activeWorld[:] process-local accessors on Object as Morphic-Kernel extensions. The actual values are stored directly on the active process in the manner of
> a ProcessSpecificVariable. For backward compatibility, the global variables are still kept up to date here.
> * Added #activateHand:during: and #activateWorld:during: as dynamic scope setters on Object as Morphic-Kernel extensions.
> * Replaced all references to ActiveEvent, ActiveHand, and ActiveWorld by "self activeEvent", "self activeHand", and "self activeWorld" accordingly. I also spent some time reflecting in which cases you actually would like to
> receive a possible nil value and ended up with changing the most senders that are not involved into the critical event processing logic into their "#current*" equivalents (#currentEvent, #currentHand, and #currentWorld)
> which already guarantee to return non-nil values. In the case of #currentWorld, I also replaced many senders with "Project current world" that were not invoked in an event-related context.
> * While skimming over all the implementations, I also applied a number of really minor refactorings: improve multilingual support by adding some "#translated"s to user strings, remove nil checks that could never be reached,
> and reformat some of the very hardest to read methods I came across.
>
>
> Please review! I'm looking forward to eliminating these unnecessary artifacts of global state and making Squeak an even more purely object-oriented and modular system by merging these changes into the Trunk.
>
>
> Best,
>
> Christoph
>
>
> [1] https://github.com/hpi-swa-teaching/AutoTDD
>
> [2] https://github.com/codeZeilen/SqueakByExample-english/
>
>
>
More information about the Squeak-dev
mailing list
|