[jboss-dev-forums] [Embedded JBoss Development] - Re: Embedded API Design Problems

jason.greene@jboss.com do-not-reply at jboss.com
Thu Dec 3 17:20:18 EST 2009


I disagree with the server factory example in Rule 4. IllegalArgumentException is the appropriate exception to be thrown since, if you look at the code, it pertains to the parameters that are passed to the method. It is true that the exceptions is thrown by a different class, but this class is the implementation of the API. So as long as the behavior is consistent to the API then this is fine.  There is definitely no need to transfrom IllegalArgumentException into a checked exception, as it is a pure runtime error that indicates misuse of the API. In other words, it is more of an assertion than it is a true exceptional condition.

I am indifferent on putting RuntimeExceptions in the throws clause. At the end of the day, it doesn't really matter, and usage of the javadoc @throws is just as effective IMO.

I do agree with the API consistency argument, however I disagree with using get/set with method chaining. If you are doing a DSL style method chain, you don't need get/set, its just extra verbosity. Get is logically the no-arg version, and Set is logically the version which takes arguments. In general I think Java developers took the JavaBean recomendations WAY to far. The whole reason JavaBeans required get & set notation was so that an automated tool could figure out what the "properties" are. In other words, JavaBeans are a big hack.

Also, as a more general comment, Bloch's advice is just that, advice. API design is somewhat subjective, so we shouldn't treat them as hard and fast rules.



View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4268875#4268875

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4268875



More information about the jboss-dev-forums mailing list