2009/11/1 Lukas Renggli <[email protected]>:
>> Obviously i can't. Because if i make all of the tree to be a subclass
>> of LoggedAnnouncement, then all of them
>> will be logged, while i want only some of them.
>
> You are missing the point of announcements: they are not supposed to
> do anything, they are only supposed to notify interested parties about
> something. It is the sole responsibility of the interested party to
> register for announcements. If somebody is interested logging some
> announcement, then this interested party should declare that wish. The
> announcement itself shouldn't care.
>
Hmm.. i don't think that i'm missing the point.
Where in this code:
annoucer on: LoggedAnnouncement do: [:ann | Transcript show: ann message ].
you see that i'm putting a responsibility for handling the
announcement on announcement,
instead of subscriber?
Subscriber provides a block, and given that LoggedAnnouncement
implements #message , it simply using it.
But subscriber is free to do anything he likes to in the handler
block, so again, i don't see where i putting any responsibility
on announcement instead of subscriber.
Oh, wait.. you mean that if i want, say 35 out of 50 announcement
kinds to be logged, then
i need to do something like:
logblock := [:announcement | ... ].
announcer on: AnnouncementKind1 do: logblock.
announcer on: AnnouncementKind2 do: logblock.
....
announcer on: AnnouncementKind35 do: logblock.
?
Do you agree that this is far from being short and elegant? Moreover
it imposes dependency from various kinds of events, instead of just
one (LoggedAnnouncement),
and, if i going to change them somehow, i would need to revisit this
code again.. and again.
I used this case to illustrate, that single inheritance , which used
in Annoucements framework not always sufficient.
In this case, it would need to overrride
Announcement class>>handles: anAnnouncementClass
^ anAnnouncementClass isKindOf: self
in LoggedAnnouncement , to something like:
LoggedAnnouncement class>>handles: anAnnouncementClass
^ anAnnouncementClass isLoggedAnnouncement
and provide a default #isLoggedAnnouncement implementation in
Announcement class.
as well as in any my own classes, override it to answer true.
So, to implement this scenario i need substantional efforts to be
taken. And already will need to extend Announcement class.
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
--
Best regards,
Igor Stasenko AKA sig.
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project