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
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:
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."