On 10 Jun 2015, at 17:13, Martin Dias <tinchodias@gmail.com> wrote:

Hi everybody,

I'm writing you to discuss about a new feature for Pharo. I would like to know your opinions and ideas. Thanks in advance.

My point is that there are operations like "MC version load", "change set file in", "RB refactoring execution", or "class copy" that produce code change announcements (e.g. ClassAdded or MethodAdded), but subscribers can't know that. I mean, a subscriber that listens a ClassAdded can't know if it is product of a "high-level" operation, or if it was manually performed by the user in the Nautilus browser. 

I think Pharo should provide a way to detect this information, because it can be very useful. For example, I can tell you about a tool I work on: Epicea. Epicea logs code changes while developer works (like traditionally done with the .changes file), and the user can browse, undo and redo changes. Now, imagine that your vm crashed and then you want to recover "lost" changes... you don't want to see hundreds of changes produced by Monticello when loading packages: in this case, such changes are noise and make you waste time when selecting what to redo. In Epicea package I have a workaround for detecting some "high-level" operations, but Epicea would need support from Pharo for a nice implementation.

Brainstorming on implementations. 

I think announcements are a good mechanism to implement this feature. A simple approach is to provide begin and end announcements (e.g. MCVersionLoadBegin and MCVersionLoadEnd). Then, somebody that subscribes to such announcements can have a stack or state machine to know the context where each code change announcement is produced. It would look like:

MCVersionLoader >> load
   ...
   SystemAnnouncer uniqueInstance announce: (MCVersionLoadBegin versionName: ...).
   [ ... produce code changes ... ] ensure: [
      SystemAnnouncer uniqueInstance announce: (MCVersionLoadEnd versionName: ...) ].

which may be re-written with a convenience method as:
   ...
   SystemAnnouncer uniqueInstance 
      announceBefore: (MCVersionLoadBegin versionName: ...)
      announceAfter: (MCVersionLoadEnd versionName: ...)
      do: [ ... produce code changes ... ] 

but, going one step further, we could reify the concept of announcement begin and end like:
   ...
   announcement := (MCVersionLoad versionName: ...).
   SystemAnnouncer uniqueInstance 
      announceBefore: (AnnouncementBegin of: announcement)
      announceAfter: (AnnouncementEnd of: announcement)
      do: [ ... produce code changes ... ] 

which could be re-written as:
   ...
   SystemAnnouncer uniqueInstance 
      announceBeforeAndAfter: (MCVersionLoad versionName: ...)
      do: [ ... produce code changes ... ] 

I think any approach can work, but I'd love to have some feedback.

I like the idea. What I���m afraid of is however, that the dependency between begin and end announcements is implicit in your examples. The only things that tell you that they belong together are the convenience implementation on SystemAnnouncer and the naming. I���m not familiar enough with announcements to post example code.
The other thing would maybe be to force subscribers to subscribe to both announcements (again, not sure how).
My point is, I want to look at one of the announcements and see that I have to work with a set of announcements.

Ben���s idea of hierarchichal announcements sounds pretty interesting. Maybe this is too restricting but how about saying: there exists a dependency between two announcements A and B such that whenever A is being announced, B has to have been announced before (I���ll leave the implementation to others :p).

The other thing would be to clean up the announcer situation��� Maybe the announcers should be hierarchical, not the announcements. Doru did a presentation at ESUG about an idea for a logging framework that uses announcements by using different announcers for different levels of interest (https://youtu.be/keqdqFu1ejk?t=10m55s). That way, if you���re interested in what MC does in the abyss of MC hell you can subscribe to the MCAbyssAnnouncer, if you want high level change events you subscribe to the MCInterestingChangeAnnouncer.

I hope you can make some use of my ramblings (last exam tomorrow, just taking a break here :) )

Cheers,
Max



Kind regards,
Mart��n