Answer the question
In order to leave comments, you need to log in
What do you think will be right?
I am writing an event system. I decided to do this:
There is an interface that describes events (event = method in i-face). And also the objects that implement it, if they want to receive such an event.
The project has a very large field from where (and where) you can throw an exception, as well as the nesting of objects. To do this, we introduced the Scope enum (in short, the values are such - globally, channel, object, up / down by object, current model, etc.). The question arose, how best to determine where the event should go (i.e. where to specify the Scope)?
A small vote:
1) When throwing an event, Scope is specified, that is, there will be some kind of service with the
dispatchEvent(Scope scope, interface, ...) method that will determine the objects (with the desired interface) that should receive the event
2) The event is thrown globally (to all objects at once), and to each method (in the implementation class) make an annotation to indicate = from where the object WANTS to receive events.
3) Annotate Scope on the interface itself.
4) A similar option with the second method, but specify the annotation NOT IN THE IMPLEMENTATION CLASS, but directly on the event interface method.
You can vote for several options, as well as offer your own options.
Criticism, wishes - are welcome
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question