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 |
||
| 8 | class Component_number |
||
| 9 | extends AbstractComponent |
||
|
|
|||
| 10 | { |
||
| 11 | View Code Duplication | public function default_model() |
|
| 12 | { |
||
| 13 | return array( |
||
| 14 | 'name' => '', |
||
| 15 | 'disabled' => false, |
||
| 16 | 'size' => null, |
||
| 17 | 'min' => null, |
||
| 18 | 'max' => null, |
||
| 19 | 'step' => null, |
||
| 20 | 'required' => false, |
||
| 21 | 'readonly' => false |
||
| 22 | ); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function required_arguments() |
||
| 29 | |||
| 30 | public function get_template_path() |
||
| 34 | } |