I would like to hear your opinion on the use of the observer pattern.
My goal is to implement one specific observer class that can listen to several observables.
If I create every other observer, as shown below, then it will be simple, as shown below.
public class ConcreteObserver implements EventObserverA , EventObserverB {
updateEventA(EventA event) {}
updateEvetnB(EventB event) {}
}
In this case, I have to write a lot of different observable / observable classes / interfaces with almost the same piece of code inside.
To avoid issues like the one above, I would like to generate an observer /, but as you guys know that the multiple inheritance rule does not allow the use of code, as shown below.
public class ConcreteObserver implements Observer<EventA> , Observer<EventB> {
update(EventA event) {}
update(EventB event) {}
}
, , , , / .
, , , n: 1: , 1: n : .
?