The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Announcement Reflections

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Announcement Reflections Posted: Nov 30, 2005 12:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Announcement Reflections
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Rich Demers and I have been having a discussion about Announcements and documentation and reflectivity and that sort of thing.

Simplistically speaking, determining what a given object announces should be able to be introspected by finding any references to Announcement subclasses within the given object's methods. This seemed like a cool idea, because, it's so... I don't know what the right word is.

I tried to use the MethodCollector stuff to do it for me, but I couldn't determine how to a) search a class heirarchy, but only upwards (the existing one goes up AND down from the target class) and b) search for class references based on the condition that the subclass inheritsFrom: Announcement. So I cobbled the following workspace script together:

class := SUnit.TestCase.
announcementTypes := Set new.
class withAllSuperclasses do: 
		[:eachClass | 
		eachClass selectorsAndMethodsDo: 
				[:yuck :eachMethod | 
				eachMethod literalsDo: 
						[:eachLiteral | 
						binding := eachLiteral isBindingReference 
									ifTrue: [eachLiteral bindingOrNil]
									ifFalse: 
										[eachLiteral isVariableBinding ifTrue: [eachLiteral binding] ifFalse: [nil]].
						(binding notNil and: [binding isForClass and: [binding value inheritsFrom: Announcement]]) ifTrue: [announcementTypes add: binding value]]]].
announcementTypes

Since SUnit.TestCase "announces" three kinds of Announcements. I should see them. And indeed it works: Failure, Pass, SomeError. Kinda. I note some interesting things.

First of all, if you were to document the "announcement interface" of TestCase, it would probably best to do it with the abstract Announcement: Result, because they all inherit from that. One could try to do some sort of analysis/heuristic, but I think it'd be tricky to get right.

Second, the thing lied. TestCase doesn't actually announce: those types. TestCase class does. But it's driven from the instance side. If an object was both subscribing to, and announcing others, the best you could actually call this computation would be something like "Announcements this object participates in."

Third, I thought I'd try another one of the objects I'm in the process of switching to use Announcements. It had none. Because the creation of the Announcement object is something the announcer lets one of it's underlings do.

Maybe I'm cheating to much with these announcement things and not "playing by the rules."

Read: Announcement Reflections

Topic: Weekly Log Analysis: 11/26/2005 Previous Topic   Next Topic Topic: Finally Civ 4!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use