Cluelessness as Design Principle

Leave a comment

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: