Re: Duplication in events mechanisms in java?

From: Tomer Ben-David (tomerbd_at_barak-online.net)
Date: 12/22/03


Date: 21 Dec 2003 23:10:39 -0800


> > java.util.Observable
> > java.util.Observer
> >
> > They seem OK to me...
>
> No, they are not ok for non trivial event systems, because:

I'm not plaining on using them directly I'm planning on building an
architecture that is going to be based on them (or on the other kind
of event architecture : java.util.EventListener)) that means that I
can use them for non trivial systems, since I'm only building my
infrastructure upon them in a way where i wont see their
disadvantages.

So that means that regarding the main reason : Main reason: Observable
is a class and the minor reason I was going to overcome them (easily)
by building my own infrastracture upon the observer/observabale ...

So I still have my question, I'm looking for the base, the common
ground of events system to build my architecture upon, I see two such
systems in java

the observer/observabale & EventListener , both these infrastructures
are solving a case where one part of the system needs to notify/send
events to other parts of the system, why dont they have a common
ground? (perhaps in a way of common ancestor interfaces) When
building an events sytem ARCHITECTURE what should it be BASED upon?
the observer/observabale or EventListener?

Thanks

Tomer

Harald Hein <speechless@gmx.de> wrote in message news:<Xns9458C36B1F29Fhhtoken@194.97.5.9>...
> "Tomer Ben-David" wrote:
>
> > Section 1 :
> >
> > java.util.Observable
> > java.util.Observer
> >
> > They seem OK to me...
>
> No, they are not ok for non trivial event systems, because:
>
> Main reason: Observable is a class. So you have to derive all event
> sources from Observable. This is to much of a restriction for a lot
> of real world systems.
>
> Minor reason: Only one type of event (the update() event) is possible.
> You have to discriminate between different events and event reasons by
> looking on the second generic argument to update(), which can become
> tedious.
>
> > My question is :
> > Why isnt there any connection between the classes/interfaces in
> > section2 to section1 isnt there actually a code duplication?!
>
> See above.
>
> > What should I use in case I want to have a generic events
> > framework in my system?
>
> You check your requirements. Depending on your requirements you use one
> of the existing mechanisms, write your own, or e.g. pay some $$$ for a
> message bus library.
>
> The better you can define your requirements, the less generic will be
> the systems that you need, and the simpler it can be.



Relevant Pages

  • Re: Duplication in events mechanisms in java?
    ... > by building my own infrastracture upon the observer/observabale ... ... > ground of events system to build my architecture upon, ... > the observer/observabale or EventListener? ... The event generator idiom as described in the article above. ...
    (comp.lang.java.programmer)
  • Re: To CS or not to CS?
    ... Sorry, I was misleading there. ... > network strained for bandwidth? ... I had thought that it WAS a reason, ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Difference Between .com & .local
    ... Rick K typed: ... So it is part of a typical AD Architecture?? ... The reason I ask is I inherited a 2003SBS network that I performed a ...
    (microsoft.public.windows.server.networking)
  • Re: Preempt-RT patch for 2.6.25
    ... no reason to hamper forward development just to keep old architecture ... ports in the tree. ... that it's a bug. ... for no good reason. ...
    (Linux-Kernel)
  • Re: [PATCH] O_NOATIME support
    ... current source layout: is there a reason for not sharing those open flags on ... an non architecture specific file? ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)