On Jan 18, 2007, at 4:36 PM, Dain Sundstrom wrote:
On Jan 18, 2007, at 4:23 PM, Alan D. Cabrera wrote:
Really? You have to grok those nested case statements and
construct the states of allowable operations in your head.
switch (currentOperation) {
case SET_CONTEXT:
case UNSET_CONTEXT:
switch(methodCategory){
case getCallerPrincipal:
case getRollbackOnly:
case isCallerInRole:
case setRollbackOnly:
case getEJBObject:
case getPrimaryKey:
case getUserTransaction:
throw new IllegalStateException
(methodCategory + "cannot be called in " + currentOperation);
}
What's to grock? For the setContext and unsetContext operations
only the listed methods can be called. Looks straight forward to me.
I'm not a big fan of switch statements and I think that the code
looks messy, jmho. Also, there's a lot more going on than just
checks for illegal states. There's access to methods that needs to
be controlled. Using this new paradigm, check statements and impls
have sprouted all over the place. Using the "old" method, the logic/
decisions are in a single place.
Regards,
Alan