August 17, 2012 by huionn
In his book “Practical API Design”, the author Jaroslav Tulach (NetBeans architect) emphasized on Cluelessness as a key principle of API design. Although I think it is nice, I am clueless about its importance.
When I studied NetBeans’s WeakListeners.propertyChange(PropertyChangeListener, Object), I am curious how can such complicated behaviors be hidden with such simple API. The WeakListener proxies the actual listener and binds to Reference Queue for detection of garbage collection. When the listener is garbage collected, the ActiveQueue deregisters the WeakListener from the source. All these are done with a lot of reflection and complicated multi-threading.
Although the implementation could be simplified with more elaborate API, the designers choose this path for the benefit of API users – cluelessness.