Say I have these lines of code in all of my controllers:
public View ControllerClass() {
// ...
// some code in controller
SomeClass someClass;
try {
someClass = Util.getParam(
context.getEncryptedParam(), soemthignElse.getSomething());
} catch (SomeException ex) {
log.error(ex);
return viewBuilderFactory.view1.view();
} catch (AnotherException ex) {
return viewBuilderFactory.view2.view();
} catch (etc ...) {}
// use someClass
// ...
return viewBuilderFactory.view3.view();
}
In this case I'd have two different return types (void and view) if I want to move the duplication to its own method. What'd be a good approach here?
Aucun commentaire:
Enregistrer un commentaire