[jboss-dev-forums] [Embedded JBoss Development] - Re: Embedded API Design Problems
david.lloyd@jboss.com
do-not-reply at jboss.com
Fri Dec 4 10:48:21 EST 2009
"richard.opalka at jboss.com" wrote : "jason.greene at jboss.com" wrote : I disagree with the server factory example in Rule 4. IllegalArgumentException is the appropriate exception to be thrown
| |
| Of course you're right Jason, the correct code should be:
|
Again, I can't agree with you. You're abiding by a set of subjective criteria as though they were laws. :-) Rather than saying "this is incorrect" what you really mean is, "this is not how I like it, but that's just my opinion".
The true test is, is the API nice to use? Does it make sense logically? If these two are true, then the API is probably just fine. Everyone has their own opinion about how APIs should look and feel, and I can tell you now that there will never be a time where everyone converges on what your (or my) idea of "right" is.
So I think a better measurement is, rather than saying "X, Y and Z violate my rules for APIs", look at what code which actually USES the API might look like and ask yourself, "can this cause a surprise for users? Is it unintuitive? Is there a way this could be made better with that in mind?" If the answer is something like "Yes, the user will need 5 probably-identical catch clauses every time they call method X, and they're all very unlikely!" then you can objectively say it's a problem. If the answer is "I don't like ____" then that's just your opinion and you should advertise it thus.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4269046#4269046
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4269046
More information about the jboss-dev-forums
mailing list