Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
17 | View Code Duplication | abstract class AbstractAction extends BaseAbstractAction |
|
18 | { |
||
19 | /** The output action socket. */ |
||
20 | const SOCKET_OUTPUT = 'out'; |
||
21 | |||
22 | /** The left variable socket. */ |
||
23 | const SOCKET_LFT = 'lft'; |
||
24 | |||
25 | /** The right variable socket. */ |
||
26 | const SOCKET_RGT = 'rgt'; |
||
27 | |||
28 | /** The result variable socket. */ |
||
29 | const SOCKET_RESULT = 'result'; |
||
30 | |||
31 | /** |
||
32 | * Initializes a new instance of this class. |
||
33 | */ |
||
34 | public function __construct() |
||
43 | |||
44 | /** |
||
45 | * Executes the node's logic. |
||
46 | */ |
||
47 | public function execute() |
||
70 | |||
71 | /** |
||
72 | * The method that calculates the value. |
||
73 | * |
||
74 | * @param double|float|int $lft The left value. |
||
75 | * @param double|float|int $rgt The right value. |
||
76 | * @return double|float|int Returns the calculated value. |
||
77 | */ |
||
78 | abstract protected function calculateValue($lft, $rgt); |
||
79 | } |
||
80 |