Pharo-users
By thread
pharo-users@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
April 2021
- 44 participants
- 149 messages
Re: creating a subclass in system browser
by kmo
This shows the browser button for a subclass on Pharo 9 on Linux (not the
very latest Version 9 by the way). It only appears when you have the class
definition tab selected.
I hope this shows up - I posted it earlier but it just hasn't appeared in
the list - so I'm posting it again. With my luck it will probably appear
twice now. <http://forum.world.st/file/t368903/subclassbutton.png>
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
April 27, 2021
Re: Announcements - and whether its bad to check if a subscription would be handled?
by Richard Sargent
I have seen something called upcasting and downcasting (as contrasted with broadcasting). Mostly, I have seen it in UI layers.
e.g. a leaf node receives a change notification, decides it isn't interested in handling the notification, and so passes it up to its parent, etc.
Downcasting is similar but in the opposite direction. e.g. a window receives an event and asks its children to handle it, and they do the same. In this case especially, the one that handles the event needs to mark it as handled so that no one else is asked to handle it.
On April 27, 2021 5:49:56 AM HST, Tim Mackinnon <tim(a)testit.works> wrote:
>Hi guys - yes that fire and forget was always how I had viewed
>announcements, and potentially my scenario is misusing "announcements"
>which is why I was interested in views here.
>
>However - as announcements are typically a mechanism for farming out
>processing to others - how does one handle the scenario that you might
>only want one object to handle the announcement (and not others)?
>
>in my specific example, with MVP - a view, totally decoupled in a web
>browser, wants to pass on a button click to a presenter - however it
>not clear what the best mechanism to bubble up that handling should be?
>If the immediate presenter of the view can handle it - great - but if
>not, how would you continue to broadcast wider to see if someone higher
>up the parent component chain can handle it?
>
>If you go fire and forget (which is how I had viewed announcements
>prior to this specific case) - then you have the problem a different
>way - when someone processes an announcement it might already have been
>handled earlier and so the consumer either has to check first, or their
>work is simply ignored as the announcement payload could just filter a
>response out.
>
>In my head, I'm sort of thinking this is akin to CPU interrupt chaining
>- where an interrupt can cascade up a stack if not handled OR like
>object inheritance where an object can choose to override a message and
>stop it from cascading up the inheritance chain.
>
>Maybe announcements aren't intended for this at all - although it seems
>an elegant way to handle it - with just 1 method addition to Announcer
>(but it does slightly expose things - albeit in a structured way - and
>similar to the similar #hasSubscriber:).
>
>I'm sure it "depends" - but interested in other observations from the
>field, as I'm sure I'm not the first person to hit something like this.
>
>Tim
>
>On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
>> The whole idea is to decouple producers and consumers, like in
>> messaging systems.
>>
>> You should not care if there are other listening, just like the
>> listeners should not care if there is someone posting data.
>>
>> Asking for subscribers is introducing a coupling.
>>
>> The announcement mechanism will/should deal with this in an efficient
>way.
>>
>> > On 27 Apr 2021, at 16:03, Tim Mackinnon <tim(a)testit.works> wrote:
>> >
>> > From my rather long ramble below - I am still curious if its
>distasteful to have a method on Announcer
>> >
>> > hasSubscriptionsHandling: anAnnouncement
>> > "Answer true if I have any subscribers to anAnnouncement"
>> >
>> > ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
>> >
>> > Tim
>> >
>> > On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
>> >> Hi everyone - Iâve always thought the article on announcements
>many
>> >> years ago was very cool - and we donât seem to use them as much as
>we
>> >> could (but equally they arenât a panacea to be overused everywhere
>
>> >> either - and they do get used in Pharo to some extent).
>> >>
>> >> Anyway, Iâve been playing around with CodeParadise (CP is a very
>cool
>> >> project, and Erik is very supportive and thinking about how to
>write
>> >> web apps a different way⦠Iâm fascinated),
>> >>
>> >> And - CP uses announcements as mechanism to send events from the
>View
>> >> Client (in a web browser) to a Presenter on the server (which
>makes
>> >> total sense).
>> >>
>> >> In taking things for a spin, I hit an interesting problem on how
>in a
>> >> web component world, you should display a spelling test of words -
>
>> >>
>> >> e.g. SpellingTest â has many â> SpellingWord(s).
>> >>
>> >>
>> >> Initially I bunged it all in a single presenter with its
>associated
>> >> view, and it was a bit messy, and Erik guided me down a route
>(that CP
>> >> nicely supports) - that my SpellingTest view should have the
>name/date
>> >> of the test as well as an add word input field, but the list of
>current
>> >> Words (which I had bunged into a table) - were actually more
>elegant as
>> >> sub-components - hence a WordView - which renders a single word in
>a
>> >> DIV, and for the edit screen I was creating, a Delete button next
>to
>> >> the word (so you could delete it). So a 1 to many relationship
>> >> essentials.
>> >>
>> >> This is where the announcements kick in (and lead to my ultimate
>question).
>> >>
>> >> When you click the Delete button, if I use a sub component - my
>view
>> >> will generate a DeleteWordAnnouncement - which gets fed to my
>> >> SpellingWordPresenter - however words in this sense donât
>naturally
>> >> know their parent (the SpellingTest) - and its the parent test
>that has
>> >> a #deleteWord: method.
>> >>
>> >> Iâve been taking with Erik, on different ways to elegantly handle
>this.
>> >>
>> >> a) you could change the model so words know their parent (in my
>case,
>> >> Iâm using a 3rd party model for Flashcards, and they just donât
>know
>> >> this - and adapting them would be a nuisance
>> >> b) my TestPresenter could listen to announcements on the
>WordPresenter
>> >> - and I could get some communications between presenters (although
>
>> >> normally the Presenters just get events from Views, and pure
>domain
>> >> models - so it feels a bit abnormal to consider another Presenter
>as a
>> >> sort of model - but I could live with this
>> >> c) given the composable nature of views/presenters (and CP is base
>on a
>> >> WebComponent model) - you could bubble up Announcements, so that
>if an
>> >> event isnât handled by a viewâs immediate presenter, you could
>re-route
>> >> it to the parent of the View (the component owner) and see if itâs
>
>> >> presenter could do something.
>> >>
>> >>
>> >> I think (c) has a certain expectation to it - in fact when I
>converted
>> >> my initial one-presenter attempt into components, I still had
>listener
>> >> code in my TestPresenter that was expecting to get a deleteWord
>> >> announcement and I was initially surprised that I wasnât getting
>it (as
>> >> it was now just going to the Word component I had refactored out).
>
>> >>
>> >> So I wonder if others here would expect things to work this way
>too
>> >> (and are there other examples in the wild that lead you here - or
>scare
>> >> you away from this?).
>> >>
>> >> Back to my Announcement question - if C is a good idea - why
>doesnât
>> >> the Announcer class let you check if if will handle a particular
>> >> announcement? The API has #hasSubscriber: and
>#hasSubscriberClass: ,
>> >> but its missing:
>> >>
>> >> hasSubscriptionsHandling: anAnnouncement
>> >> "Answer true if I have any subcribers to anAnnouncement"
>> >>
>> >> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
>> >>
>> >>
>> >> And I am wondering if this is because it's a bad thing to expect
>to be
>> >> able to check? In my case above, I would want to do this to know
>if CP
>> >> should instead try announcing a message to a parent presenter
>because
>> >> the current presenter wonât handle it. In my example above, my
>> >> WordComponentView will broadcast that the delete button was
>clicked,
>> >> but its actually a parent view which would reasonably want to
>listen to
>> >> this kind of event and process the delete. And in a many words
>> >> scenario (the Test has many words), its unrealistic for the parent
>to
>> >> register to listen to each word component individually (in fact CP
>sort
>> >> of hides this from you), however if you could listen to an event
>in
>> >> your TestView, it seems to come out quite nicely - and looks a
>bit
>> >> like this:
>> >>
>> >> viewCreated
>> >> super viewCreated.
>> >>
>> >> self view
>> >> when: CpNavigationAnnouncement
>> >> do: [ :action | self model goto: action location ];
>> >>
>> >> when: CpAddWordAnnouncement do: [ :action | self addWord: action
>data
>> >> ];
>> >> when: CpDeleteWordAnnouncement do: [ :action | self deleteWord:
>> >> action data ]. <â this is the one Iâm talking about
>> >>
>> >>
>> >> So Iâm curious on the overall thought process here, but in
>particular
>> >> whether I should even submit a PR on Announcer for
>> >> #hasSubscriptionsHandling: ?
>> >>
>> >> Tim
>> >>
>> >>
>>
April 27, 2021
Re: creating a subclass in system browser
by Russ Whaley
Ah, in my v9 version, I see a red circled exclamation point (hovering says
'Refactorings' - which has a menu for the +New subclass.
Good to know! Thanks!
On Tue, Apr 27, 2021 at 12:17 PM kmo <voxkmp(a)gmail.com> wrote:
> I've attached a screenshot. The button appears when you select the class
> definition tab in the browser. Press it and you get a dialog to enter a
> subclass name then the text
> <http://forum.world.st/file/t368903/subclassbutton.png> template for that
> subclass appears in the browser class definition tab.
>
> This is from Pharo 9 on Linux (this is an older version 9 - not the very
> latest)
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
--
Russ Whaley
whaley.russ(a)gmail.com
April 27, 2021
Re: Announcements - and whether its bad to check if a subscription would be handled?
by John Aspinall
The MVP scenario you describe with âbubbling upâ of event handling is how Dolphin implements command routing in MVP. Iâd suggest that what you need is an implementation of this, which is a separate mechanism to Announcements.
Possibly your suggested solution is a clever way to implement a command mechanism by piggybacking Announcements..?
> On 27 Apr 2021, at 16:49, Tim Mackinnon <tim(a)testit.works> wrote:
>
> Hi guys - yes that fire and forget was always how I had viewed announcements, and potentially my scenario is misusing "announcements" which is why I was interested in views here.
>
> However - as announcements are typically a mechanism for farming out processing to others - how does one handle the scenario that you might only want one object to handle the announcement (and not others)?
>
> in my specific example, with MVP - a view, totally decoupled in a web browser, wants to pass on a button click to a presenter - however it not clear what the best mechanism to bubble up that handling should be? If the immediate presenter of the view can handle it - great - but if not, how would you continue to broadcast wider to see if someone higher up the parent component chain can handle it?
>
> If you go fire and forget (which is how I had viewed announcements prior to this specific case) - then you have the problem a different way - when someone processes an announcement it might already have been handled earlier and so the consumer either has to check first, or their work is simply ignored as the announcement payload could just filter a response out.
>
> In my head, I'm sort of thinking this is akin to CPU interrupt chaining - where an interrupt can cascade up a stack if not handled OR like object inheritance where an object can choose to override a message and stop it from cascading up the inheritance chain.
>
> Maybe announcements aren't intended for this at all - although it seems an elegant way to handle it - with just 1 method addition to Announcer (but it does slightly expose things - albeit in a structured way - and similar to the similar #hasSubscriber:).
>
> I'm sure it "depends" - but interested in other observations from the field, as I'm sure I'm not the first person to hit something like this.
>
> Tim
>
> On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
>> The whole idea is to decouple producers and consumers, like in
>> messaging systems.
>>
>> You should not care if there are other listening, just like the
>> listeners should not care if there is someone posting data.
>>
>> Asking for subscribers is introducing a coupling.
>>
>> The announcement mechanism will/should deal with this in an efficient way.
>>
>>> On 27 Apr 2021, at 16:03, Tim Mackinnon <tim(a)testit.works> wrote:
>>>
>>> From my rather long ramble below - I am still curious if its distasteful to have a method on Announcer
>>>
>>> hasSubscriptionsHandling: anAnnouncement
>>> "Answer true if I have any subscribers to anAnnouncement"
>>>
>>> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
>>>
>>> Tim
>>>
>>> On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
>>>> Hi everyone - Iâve always thought the article on announcements many
>>>> years ago was very cool - and we donât seem to use them as much as we
>>>> could (but equally they arenât a panacea to be overused everywhere
>>>> either - and they do get used in Pharo to some extent).
>>>>
>>>> Anyway, Iâve been playing around with CodeParadise (CP is a very cool
>>>> project, and Erik is very supportive and thinking about how to write
>>>> web apps a different way⦠Iâm fascinated),
>>>>
>>>> And - CP uses announcements as mechanism to send events from the View
>>>> Client (in a web browser) to a Presenter on the server (which makes
>>>> total sense).
>>>>
>>>> In taking things for a spin, I hit an interesting problem on how in a
>>>> web component world, you should display a spelling test of words -
>>>>
>>>> e.g. SpellingTest â has many â> SpellingWord(s).
>>>>
>>>>
>>>> Initially I bunged it all in a single presenter with its associated
>>>> view, and it was a bit messy, and Erik guided me down a route (that CP
>>>> nicely supports) - that my SpellingTest view should have the name/date
>>>> of the test as well as an add word input field, but the list of current
>>>> Words (which I had bunged into a table) - were actually more elegant as
>>>> sub-components - hence a WordView - which renders a single word in a
>>>> DIV, and for the edit screen I was creating, a Delete button next to
>>>> the word (so you could delete it). So a 1 to many relationship
>>>> essentials.
>>>>
>>>> This is where the announcements kick in (and lead to my ultimate question).
>>>>
>>>> When you click the Delete button, if I use a sub component - my view
>>>> will generate a DeleteWordAnnouncement - which gets fed to my
>>>> SpellingWordPresenter - however words in this sense donât naturally
>>>> know their parent (the SpellingTest) - and its the parent test that has
>>>> a #deleteWord: method.
>>>>
>>>> Iâve been taking with Erik, on different ways to elegantly handle this.
>>>>
>>>> a) you could change the model so words know their parent (in my case,
>>>> Iâm using a 3rd party model for Flashcards, and they just donât know
>>>> this - and adapting them would be a nuisance
>>>> b) my TestPresenter could listen to announcements on the WordPresenter
>>>> - and I could get some communications between presenters (although
>>>> normally the Presenters just get events from Views, and pure domain
>>>> models - so it feels a bit abnormal to consider another Presenter as a
>>>> sort of model - but I could live with this
>>>> c) given the composable nature of views/presenters (and CP is base on a
>>>> WebComponent model) - you could bubble up Announcements, so that if an
>>>> event isnât handled by a viewâs immediate presenter, you could re-route
>>>> it to the parent of the View (the component owner) and see if itâs
>>>> presenter could do something.
>>>>
>>>>
>>>> I think (c) has a certain expectation to it - in fact when I converted
>>>> my initial one-presenter attempt into components, I still had listener
>>>> code in my TestPresenter that was expecting to get a deleteWord
>>>> announcement and I was initially surprised that I wasnât getting it (as
>>>> it was now just going to the Word component I had refactored out).
>>>>
>>>> So I wonder if others here would expect things to work this way too
>>>> (and are there other examples in the wild that lead you here - or scare
>>>> you away from this?).
>>>>
>>>> Back to my Announcement question - if C is a good idea - why doesnât
>>>> the Announcer class let you check if if will handle a particular
>>>> announcement? The API has #hasSubscriber: and #hasSubscriberClass: ,
>>>> but its missing:
>>>>
>>>> hasSubscriptionsHandling: anAnnouncement
>>>> "Answer true if I have any subcribers to anAnnouncement"
>>>>
>>>> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
>>>>
>>>>
>>>> And I am wondering if this is because it's a bad thing to expect to be
>>>> able to check? In my case above, I would want to do this to know if CP
>>>> should instead try announcing a message to a parent presenter because
>>>> the current presenter wonât handle it. In my example above, my
>>>> WordComponentView will broadcast that the delete button was clicked,
>>>> but its actually a parent view which would reasonably want to listen to
>>>> this kind of event and process the delete. And in a many words
>>>> scenario (the Test has many words), its unrealistic for the parent to
>>>> register to listen to each word component individually (in fact CP sort
>>>> of hides this from you), however if you could listen to an event in
>>>> your TestView, it seems to come out quite nicely - and looks a bit
>>>> like this:
>>>>
>>>> viewCreated
>>>> super viewCreated.
>>>>
>>>> self view
>>>> when: CpNavigationAnnouncement
>>>> do: [ :action | self model goto: action location ];
>>>>
>>>> when: CpAddWordAnnouncement do: [ :action | self addWord: action data
>>>> ];
>>>> when: CpDeleteWordAnnouncement do: [ :action | self deleteWord:
>>>> action data ]. <â this is the one Iâm talking about
>>>>
>>>>
>>>> So Iâm curious on the overall thought process here, but in particular
>>>> whether I should even submit a PR on Announcer for
>>>> #hasSubscriptionsHandling: ?
>>>>
>>>> Tim
>>>>
>>>>
>>
April 27, 2021
Re: creating a subclass in system browser
by kmo
I've attached a screenshot. The button appears when you select the class
definition tab in the browser. Press it and you get a dialog to enter a
subclass name then the text
<http://forum.world.st/file/t368903/subclassbutton.png> template for that
subclass appears in the browser class definition tab.
This is from Pharo 9 on Linux (this is an older version 9 - not the very
latest)
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
April 27, 2021
Re: creating a subclass in system browser
by Russ Whaley
Thanks Sanjay... I don't use v8. I'm heavily invested in Spec2 and, well,
my apps won't run in v8 :)
On Tue, Apr 27, 2021 at 11:15 AM Sanjay Minni <sm(a)planage.com> wrote:
> Don't think it's there in v9. Check in v8
>
> On Tue, 27 Apr, 2021, 7:50 pm Russ Whaley, <whaley.russ(a)gmail.com> wrote:
>
>> Can you send a screenshot of the plus button? I'm using v9 on MacOS and
>> I don't see a class + button...
>>
>> On Tue, Apr 27, 2021 at 9:47 AM kmo <voxkmp(a)gmail.com> wrote:
>>
>>> Doing it by hand is fiddly and error-prone. I know - because that's the
>>> way I
>>> used to do it before I realised that the plus button at the top of the
>>> browser bottom panel did it for me. (I had no idea that there was also a
>>> menu option on the refactorings menu). I think you might find the button
>>> to
>>> be the better way - I did.
>>>
>>>
>>>
>>>
>>> --
>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>>
>>
>>
>> --
>> Russ Whaley
>> whaley.russ(a)gmail.com
>>
>
--
Russ Whaley
whaley.russ(a)gmail.com
April 27, 2021
Re: Announcements - and whether its bad to check if a subscription would be handled?
by Esteban Maringolo
The bubbling up is very common in UI, I don't know how it is implemented
though.
I don't know if event handling is programmed using events or imperative
calls to continue "bubbling" up, or... the event is handler by the
container presenter and passed down to the target (e.g. a button).
So the end user of the event registers the handling of an event directly at
the component (presenter in MVP), regardless of who fires it. And it is the
event object or the listener of the event that decides to stop its
propagation.
Regards,
Esteban A. Maringolo
On Tue, Apr 27, 2021 at 12:50 PM Tim Mackinnon <tim(a)testit.works> wrote:
> Hi guys - yes that fire and forget was always how I had viewed
> announcements, and potentially my scenario is misusing "announcements"
> which is why I was interested in views here.
>
> However - as announcements are typically a mechanism for farming out
> processing to others - how does one handle the scenario that you might only
> want one object to handle the announcement (and not others)?
>
> in my specific example, with MVP - a view, totally decoupled in a web
> browser, wants to pass on a button click to a presenter - however it not
> clear what the best mechanism to bubble up that handling should be? If the
> immediate presenter of the view can handle it - great - but if not, how
> would you continue to broadcast wider to see if someone higher up the
> parent component chain can handle it?
>
> If you go fire and forget (which is how I had viewed announcements prior
> to this specific case) - then you have the problem a different way - when
> someone processes an announcement it might already have been handled
> earlier and so the consumer either has to check first, or their work is
> simply ignored as the announcement payload could just filter a response out.
>
> In my head, I'm sort of thinking this is akin to CPU interrupt chaining -
> where an interrupt can cascade up a stack if not handled OR like object
> inheritance where an object can choose to override a message and stop it
> from cascading up the inheritance chain.
>
> Maybe announcements aren't intended for this at all - although it seems an
> elegant way to handle it - with just 1 method addition to Announcer (but it
> does slightly expose things - albeit in a structured way - and similar to
> the similar #hasSubscriber:).
>
> I'm sure it "depends" - but interested in other observations from the
> field, as I'm sure I'm not the first person to hit something like this.
>
> Tim
>
> On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
> > The whole idea is to decouple producers and consumers, like in
> > messaging systems.
> >
> > You should not care if there are other listening, just like the
> > listeners should not care if there is someone posting data.
> >
> > Asking for subscribers is introducing a coupling.
> >
> > The announcement mechanism will/should deal with this in an efficient
> way.
> >
> > > On 27 Apr 2021, at 16:03, Tim Mackinnon <tim(a)testit.works> wrote:
> > >
> > > From my rather long ramble below - I am still curious if its
> distasteful to have a method on Announcer
> > >
> > > hasSubscriptionsHandling: anAnnouncement
> > > "Answer true if I have any subscribers to anAnnouncement"
> > >
> > > ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
> > >
> > > Tim
> > >
> > > On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
> > >> Hi everyone - Iâve always thought the article on announcements many
> > >> years ago was very cool - and we donât seem to use them as much as we
> > >> could (but equally they arenât a panacea to be overused everywhere
> > >> either - and they do get used in Pharo to some extent).
> > >>
> > >> Anyway, Iâve been playing around with CodeParadise (CP is a very cool
> > >> project, and Erik is very supportive and thinking about how to write
> > >> web apps a different way⦠Iâm fascinated),
> > >>
> > >> And - CP uses announcements as mechanism to send events from the View
> > >> Client (in a web browser) to a Presenter on the server (which makes
> > >> total sense).
> > >>
> > >> In taking things for a spin, I hit an interesting problem on how in a
> > >> web component world, you should display a spelling test of words -
> > >>
> > >> e.g. SpellingTest â has many â> SpellingWord(s).
> > >>
> > >>
> > >> Initially I bunged it all in a single presenter with its associated
> > >> view, and it was a bit messy, and Erik guided me down a route (that
> CP
> > >> nicely supports) - that my SpellingTest view should have the
> name/date
> > >> of the test as well as an add word input field, but the list of
> current
> > >> Words (which I had bunged into a table) - were actually more elegant
> as
> > >> sub-components - hence a WordView - which renders a single word in a
> > >> DIV, and for the edit screen I was creating, a Delete button next to
> > >> the word (so you could delete it). So a 1 to many relationship
> > >> essentials.
> > >>
> > >> This is where the announcements kick in (and lead to my ultimate
> question).
> > >>
> > >> When you click the Delete button, if I use a sub component - my view
> > >> will generate a DeleteWordAnnouncement - which gets fed to my
> > >> SpellingWordPresenter - however words in this sense donât naturally
> > >> know their parent (the SpellingTest) - and its the parent test that
> has
> > >> a #deleteWord: method.
> > >>
> > >> Iâve been taking with Erik, on different ways to elegantly handle
> this.
> > >>
> > >> a) you could change the model so words know their parent (in my case,
> > >> Iâm using a 3rd party model for Flashcards, and they just donât know
> > >> this - and adapting them would be a nuisance
> > >> b) my TestPresenter could listen to announcements on the
> WordPresenter
> > >> - and I could get some communications between presenters (although
> > >> normally the Presenters just get events from Views, and pure domain
> > >> models - so it feels a bit abnormal to consider another Presenter as
> a
> > >> sort of model - but I could live with this
> > >> c) given the composable nature of views/presenters (and CP is base on
> a
> > >> WebComponent model) - you could bubble up Announcements, so that if
> an
> > >> event isnât handled by a viewâs immediate presenter, you could
> re-route
> > >> it to the parent of the View (the component owner) and see if itâs
> > >> presenter could do something.
> > >>
> > >>
> > >> I think (c) has a certain expectation to it - in fact when I
> converted
> > >> my initial one-presenter attempt into components, I still had
> listener
> > >> code in my TestPresenter that was expecting to get a deleteWord
> > >> announcement and I was initially surprised that I wasnât getting it
> (as
> > >> it was now just going to the Word component I had refactored out).
> > >>
> > >> So I wonder if others here would expect things to work this way too
> > >> (and are there other examples in the wild that lead you here - or
> scare
> > >> you away from this?).
> > >>
> > >> Back to my Announcement question - if C is a good idea - why doesnât
> > >> the Announcer class let you check if if will handle a particular
> > >> announcement? The API has #hasSubscriber: and #hasSubscriberClass: ,
> > >> but its missing:
> > >>
> > >> hasSubscriptionsHandling: anAnnouncement
> > >> "Answer true if I have any subcribers to anAnnouncement"
> > >>
> > >> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
> > >>
> > >>
> > >> And I am wondering if this is because it's a bad thing to expect to
> be
> > >> able to check? In my case above, I would want to do this to know if
> CP
> > >> should instead try announcing a message to a parent presenter because
> > >> the current presenter wonât handle it. In my example above, my
> > >> WordComponentView will broadcast that the delete button was clicked,
> > >> but its actually a parent view which would reasonably want to listen
> to
> > >> this kind of event and process the delete. And in a many words
> > >> scenario (the Test has many words), its unrealistic for the parent to
> > >> register to listen to each word component individually (in fact CP
> sort
> > >> of hides this from you), however if you could listen to an event in
> > >> your TestView, it seems to come out quite nicely - and looks a bit
> > >> like this:
> > >>
> > >> viewCreated
> > >> super viewCreated.
> > >>
> > >> self view
> > >> when: CpNavigationAnnouncement
> > >> do: [ :action | self model goto: action location ];
> > >>
> > >> when: CpAddWordAnnouncement do: [ :action | self addWord:
> action data
> > >> ];
> > >> when: CpDeleteWordAnnouncement do: [ :action | self
> deleteWord:
> > >> action data ]. <â this is the one Iâm talking about
> > >>
> > >>
> > >> So Iâm curious on the overall thought process here, but in particular
> > >> whether I should even submit a PR on Announcer for
> > >> #hasSubscriptionsHandling: ?
> > >>
> > >> Tim
> > >>
> > >>
> >
>
April 27, 2021
Re: Announcements - and whether its bad to check if a subscription would be handled?
by Tim Mackinnon
Hi guys - yes that fire and forget was always how I had viewed announcements, and potentially my scenario is misusing "announcements" which is why I was interested in views here.
However - as announcements are typically a mechanism for farming out processing to others - how does one handle the scenario that you might only want one object to handle the announcement (and not others)?
in my specific example, with MVP - a view, totally decoupled in a web browser, wants to pass on a button click to a presenter - however it not clear what the best mechanism to bubble up that handling should be? If the immediate presenter of the view can handle it - great - but if not, how would you continue to broadcast wider to see if someone higher up the parent component chain can handle it?
If you go fire and forget (which is how I had viewed announcements prior to this specific case) - then you have the problem a different way - when someone processes an announcement it might already have been handled earlier and so the consumer either has to check first, or their work is simply ignored as the announcement payload could just filter a response out.
In my head, I'm sort of thinking this is akin to CPU interrupt chaining - where an interrupt can cascade up a stack if not handled OR like object inheritance where an object can choose to override a message and stop it from cascading up the inheritance chain.
Maybe announcements aren't intended for this at all - although it seems an elegant way to handle it - with just 1 method addition to Announcer (but it does slightly expose things - albeit in a structured way - and similar to the similar #hasSubscriber:).
I'm sure it "depends" - but interested in other observations from the field, as I'm sure I'm not the first person to hit something like this.
Tim
On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
> The whole idea is to decouple producers and consumers, like in
> messaging systems.
>
> You should not care if there are other listening, just like the
> listeners should not care if there is someone posting data.
>
> Asking for subscribers is introducing a coupling.
>
> The announcement mechanism will/should deal with this in an efficient way.
>
> > On 27 Apr 2021, at 16:03, Tim Mackinnon <tim(a)testit.works> wrote:
> >
> > From my rather long ramble below - I am still curious if its distasteful to have a method on Announcer
> >
> > hasSubscriptionsHandling: anAnnouncement
> > "Answer true if I have any subscribers to anAnnouncement"
> >
> > ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
> >
> > Tim
> >
> > On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
> >> Hi everyone - Iâve always thought the article on announcements many
> >> years ago was very cool - and we donât seem to use them as much as we
> >> could (but equally they arenât a panacea to be overused everywhere
> >> either - and they do get used in Pharo to some extent).
> >>
> >> Anyway, Iâve been playing around with CodeParadise (CP is a very cool
> >> project, and Erik is very supportive and thinking about how to write
> >> web apps a different way⦠Iâm fascinated),
> >>
> >> And - CP uses announcements as mechanism to send events from the View
> >> Client (in a web browser) to a Presenter on the server (which makes
> >> total sense).
> >>
> >> In taking things for a spin, I hit an interesting problem on how in a
> >> web component world, you should display a spelling test of words -
> >>
> >> e.g. SpellingTest â has many â> SpellingWord(s).
> >>
> >>
> >> Initially I bunged it all in a single presenter with its associated
> >> view, and it was a bit messy, and Erik guided me down a route (that CP
> >> nicely supports) - that my SpellingTest view should have the name/date
> >> of the test as well as an add word input field, but the list of current
> >> Words (which I had bunged into a table) - were actually more elegant as
> >> sub-components - hence a WordView - which renders a single word in a
> >> DIV, and for the edit screen I was creating, a Delete button next to
> >> the word (so you could delete it). So a 1 to many relationship
> >> essentials.
> >>
> >> This is where the announcements kick in (and lead to my ultimate question).
> >>
> >> When you click the Delete button, if I use a sub component - my view
> >> will generate a DeleteWordAnnouncement - which gets fed to my
> >> SpellingWordPresenter - however words in this sense donât naturally
> >> know their parent (the SpellingTest) - and its the parent test that has
> >> a #deleteWord: method.
> >>
> >> Iâve been taking with Erik, on different ways to elegantly handle this.
> >>
> >> a) you could change the model so words know their parent (in my case,
> >> Iâm using a 3rd party model for Flashcards, and they just donât know
> >> this - and adapting them would be a nuisance
> >> b) my TestPresenter could listen to announcements on the WordPresenter
> >> - and I could get some communications between presenters (although
> >> normally the Presenters just get events from Views, and pure domain
> >> models - so it feels a bit abnormal to consider another Presenter as a
> >> sort of model - but I could live with this
> >> c) given the composable nature of views/presenters (and CP is base on a
> >> WebComponent model) - you could bubble up Announcements, so that if an
> >> event isnât handled by a viewâs immediate presenter, you could re-route
> >> it to the parent of the View (the component owner) and see if itâs
> >> presenter could do something.
> >>
> >>
> >> I think (c) has a certain expectation to it - in fact when I converted
> >> my initial one-presenter attempt into components, I still had listener
> >> code in my TestPresenter that was expecting to get a deleteWord
> >> announcement and I was initially surprised that I wasnât getting it (as
> >> it was now just going to the Word component I had refactored out).
> >>
> >> So I wonder if others here would expect things to work this way too
> >> (and are there other examples in the wild that lead you here - or scare
> >> you away from this?).
> >>
> >> Back to my Announcement question - if C is a good idea - why doesnât
> >> the Announcer class let you check if if will handle a particular
> >> announcement? The API has #hasSubscriber: and #hasSubscriberClass: ,
> >> but its missing:
> >>
> >> hasSubscriptionsHandling: anAnnouncement
> >> "Answer true if I have any subcribers to anAnnouncement"
> >>
> >> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
> >>
> >>
> >> And I am wondering if this is because it's a bad thing to expect to be
> >> able to check? In my case above, I would want to do this to know if CP
> >> should instead try announcing a message to a parent presenter because
> >> the current presenter wonât handle it. In my example above, my
> >> WordComponentView will broadcast that the delete button was clicked,
> >> but its actually a parent view which would reasonably want to listen to
> >> this kind of event and process the delete. And in a many words
> >> scenario (the Test has many words), its unrealistic for the parent to
> >> register to listen to each word component individually (in fact CP sort
> >> of hides this from you), however if you could listen to an event in
> >> your TestView, it seems to come out quite nicely - and looks a bit
> >> like this:
> >>
> >> viewCreated
> >> super viewCreated.
> >>
> >> self view
> >> when: CpNavigationAnnouncement
> >> do: [ :action | self model goto: action location ];
> >>
> >> when: CpAddWordAnnouncement do: [ :action | self addWord: action data
> >> ];
> >> when: CpDeleteWordAnnouncement do: [ :action | self deleteWord:
> >> action data ]. <â this is the one Iâm talking about
> >>
> >>
> >> So Iâm curious on the overall thought process here, but in particular
> >> whether I should even submit a PR on Announcer for
> >> #hasSubscriptionsHandling: ?
> >>
> >> Tim
> >>
> >>
>
April 27, 2021
Re: creating a subclass in system browser
by Christopher Fuhrman
One thing I find challenging when teaching Pharo to new students --
especially those accustomed to IDEs with files, which is pretty much all of
them ;) -- is that there are *sometimes* menus (depending on the Pharo
version) to add a new package, new class, new protocol, but not a new
method, etc.
For onboarding new users, I think it's important that these things be
intuitive and consistent, especially since updating tutorials takes time.
They are super important because inconsistencies become barriers to
onboarding new people. My point here is not that a menu option necessarily
exists, but that we have a consistent way to explain how to create things
even when Pharo changes. Apple used to have 10 commandments for keyboard
shortcuts, and I think a similar idea could apply to having consistency in
these elements of Pharo.
Here are some related perspectives:
https://stackoverflow.com/questions/48034993/creation-of-a-class-in-pharo-s…
https://stackoverflow.com/questions/53374761/how-to-add-a-new-method-in-pha…
On Tue, 27 Apr 2021 at 09:47, kmo <voxkmp(a)gmail.com> wrote:
> Doing it by hand is fiddly and error-prone. I know - because that's the
> way I
> used to do it before I realised that the plus button at the top of the
> browser bottom panel did it for me. (I had no idea that there was also a
> menu option on the refactorings menu). I think you might find the button to
> be the better way - I did.
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
--
Christopher Fuhrman, P.Eng., PhD
*Professeur au Département de génie logiciel et des technologies de
l'informationÃTS (Ãcole de technologie supérieure)*
http://profs.etsmtl.ca/cfuhrman
+1 514 396 8638
*L'ÃTS est une constituante de l'Université du Québec*
April 27, 2021
Re: creating a subclass in system browser
by Sanjay Minni
Don't think it's there in v9. Check in v8
On Tue, 27 Apr, 2021, 7:50 pm Russ Whaley, <whaley.russ(a)gmail.com> wrote:
> Can you send a screenshot of the plus button? I'm using v9 on MacOS and I
> don't see a class + button...
>
> On Tue, Apr 27, 2021 at 9:47 AM kmo <voxkmp(a)gmail.com> wrote:
>
>> Doing it by hand is fiddly and error-prone. I know - because that's the
>> way I
>> used to do it before I realised that the plus button at the top of the
>> browser bottom panel did it for me. (I had no idea that there was also a
>> menu option on the refactorings menu). I think you might find the button
>> to
>> be the better way - I did.
>>
>>
>>
>>
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>
>
>
> --
> Russ Whaley
> whaley.russ(a)gmail.com
>
April 27, 2021