dybdahl/cloudname — comment on commit 75ef6eac425ec6aedfadfc35b08c6796b4ac4f93
File: cn/src/main/java/org/cloudname/Resolver.java line 69
By bakksjo:

I merged your branch and was able to see it. I don't like it. The old version was better: "For _this_ expression, register _this_ listener. Now the logic is more convoluted, and the listener interface has methods which are not part of the listener idiom. The fact that you had to add constraints to the javadoc ("this should be static data") is a symptom of unoptimal design. With the original approach, there was no need to put additional requirements on the client/implementor.

Also, it is unspecified how you handle identification in the removeResolverListener() method. Do you rely on the listeners having implemented a proper equals()/hashCode(), or do you use identity equality to locate and remove the correct listener? This is also something you don't have to communicate if you instead return a control handle.

It is always a good idea to prefer APIs that cannot be used/implemented incorrectly.