Article View: borland.public.jbuilder.java.language
Article #7312Re: user-defined events
From: Tim Dietz
Date: Tue, 26 Jun 2001 14:43
Date: Tue, 26 Jun 2001 14:43
57 lines
2911 bytes
2911 bytes
"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message news:MPG.15a1edf02782756398a2de@forums.borland.com... > On Mon, 25 Jun 2001 13:08:23 +0100, Steve Holt wrote: > > > Check out the Observer/Observable classes. > > The Observer interface and Observable class implement the Observer > pattern, but so do the Event classes mentioned in the link that > Torsten posted. Either will work, but I think the Event approach > is better. > > One reason is that Observable is a class, not an interface. Since > you must extend Observable, you cannot extend another class, which > can be a significant problem. > I'm confused here. The AWTEvent class, which is the parallel component to the Observable class in this comparison is not an interface, either. Why is it better? > Another problem is with the granularity of the notification. With > the Observer classes, every Observer is notified whenever there is > any kind change in the Observable. It is not possible to register > as an Observer for only certain kinds of changes. With the Event > classes, you can do this. > I also don't see how a generic AWTEvent class can differentiate between certain kinds of changes and an Observable class cannot. > One final argument for the Event classes: If you search the entire > source for the Java core classes, you will not find a single use of > Observer and Observable, but you will find thousands of uses of the > Event classes. > I can see using the Event classes for graphical situations (which is what the original poster was asking about), but it just seems to me that if you're not in a graphical situation where you need an Observer pattern, the Observer/ Observable classes fill the bill with less of a footprint. Just my ignorant $.02 worth. Tim > -- > Regards, > > John McGrath [TeamB] > > --------------------------------------------------- > Before sending me e-mail, please read: > http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<3b389fc3$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b36f246.4749430@newsgroups.borland.com> <3b3729ba$1_1@dnews> <MPG.15a1edf02782756398a2de@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,522cf07126eb8906 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-06-26 08:00:40 PST From: "Tim Dietz" <tdietz@telena.com> Newsgroups: borland.public.jbuilder.java.language References: <3b36f246.4749430@newsgroups.borland.com> <3b3729ba$1_1@dnews> <MPG.15a1edf02782756398a2de@forums.borland.com> Subject: Re: user-defined events Date: Tue, 26 Jun 2001 07:43:32 -0700 Lines: 59 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 207.110.36.206 Message-ID: <3b389fc3$1_2@dnews> X-Trace: dnews 993566659 207.110.36.206 (26 Jun 2001 07:44:19 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews