On Jan 18, 2007, at 5:47 PM, Alan D. Cabrera wrote:


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.


Easy come easy go I guess :) I will mourn the loss of the Alan code I love and learn to love the new Alan code :)

Couple design notes though. Use named inner classes (or top level classes) instead of anonymous inner classes as the Foo$3.class is hard to read in a stack trace. Also use enums instead of int constants. And finally, for the love of the rest of us who have to maintain all this, try and keep all the impls in one spot if you can.

-David



Regards,
Alan




Reply via email to