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 |
||
| 6 | class Account extends MY_Controller { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Constructor |
||
| 10 | */ |
||
| 11 | public function __construct() |
||
| 17 | |||
| 18 | // -------------------------------------------------------------------------- |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Dashboard |
||
| 22 | */ |
||
| 23 | public function index() |
||
| 28 | |||
| 29 | // -------------------------------------------------------------------------- |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Password change form |
||
| 33 | */ |
||
| 34 | public function password() |
||
| 65 | |||
| 66 | // -------------------------------------------------------------------------- |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Timezone update |
||
| 70 | */ |
||
| 71 | View Code Duplication | public function update_tz() |
|
| 84 | |||
| 85 | // -------------------------------------------------------------------------- |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Number format update |
||
| 89 | */ |
||
| 90 | View Code Duplication | public function update_nf() |
|
| 104 | } |
||
| 105 | // End of controllers/account.php |