I have only one class with many instances. Every instance is observer of couple of other instances. As well every instance can be observable by couple of another instances.<
One way is to only fire events like updated if something was actually updated. The benefit of this approach is that you can often reduce the number of events triggered (reducing work) and simplify the code. e.g.
final Set set = ...
public void onAdded(String string) {
// is only added once.
if (set.add(string)) {
// only notifies once no matter how many times onAdded is
// called for this string, recursively or not.
notifyAdded(string);
}
}