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 |
||
| 10 | class OrderStatusLog_DeviceDetails extends OrderStatusLog |
||
| 11 | { |
||
| 12 | private static $db = array( |
||
|
|
|||
| 13 | 'IPAddress' => 'Varchar(255)', |
||
| 14 | 'UserAgent' => 'Varchar(255)', |
||
| 15 | 'AcceptLanguage' => 'Varchar(255)', |
||
| 16 | 'SessionAge' => 'Decimal', |
||
| 17 | 'SessionID' => 'Varchar(255)' |
||
| 18 | ); |
||
| 19 | |||
| 20 | public function canCreate($member = null) |
||
| 24 | |||
| 25 | View Code Duplication | public function canEdit($member = null) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * adding a sequential order number. |
||
| 42 | */ |
||
| 43 | public function onBeforeWrite() |
||
| 64 | } |
||
| 65 |