Monday, March 16, 2015

ADF code review (crime #1)

Doing code review is like reading a mystery novel. You always wander why… and you rarely find logical answers.

An example of ADF code in managed beans:
            try {
                OperationBinding ob = ADFUtils.findOperation("Rollback");
            } catch (NullPointerException npe) {
                //Probably due to being the first time... no worries.

Why would someone want to hide such an exception?

And then you check the ADFUtils. findOperation method:

    public static OperationBinding findOperation(String name) {
        OperationBinding op = getDCBindingContainer().getOperationBinding(name);
        if (op == null) {
            throw new RuntimeException
("Operation '" + name + "' not found");
        return op;

And you see that NullPointerException will never be thrown since it is overridden with a  RuntimeException.

In any case, if there is no operation in the binding it is a development bug. Why would someone want to hide it?

One more unresolved crime…

No comments:

Post a Comment