I inherited this gigantic legacy of a Java web application using Struts 1.2.4. I have a specific question about actions. Most pages have exactly one action, and the processExecute () methods are disgusting monsters (very long and tons of nested if statements based on query parameters).
Given that Actions is an implementation of a command template, I’m going to split these actions into one action for each user gesture. It will be a lot of refactoring, though, and I'm curious:
My way to handle this:
- , ...
Struts, , . - , , Response , , .
. , , , , . Struts , , , -, .
.
. Action ( ClassA). , . Action (ClassB, ClassC). , ClassA , . , :
Original Hierarchy: New Hierarchy: Action Action | | | BaseA (old)ClassA | +--------+----------+ | | | ClassB (new)ClassA ClassC
. .
, .
, , , .
, , .
, -.
, -, "" ( , ), , .
; ... - - ... struts / .
, switch, ( - ).
, , , , , /, . ifs, , , .
enum Operation { ADD, DELETE; } ... Operation operation = determineOperation(form); if (operation == Operation.DELETE) { doDelete(form); } else if (operation == Operation.ADD) { doAdd(form); }
- , . , , .