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 |
||
21 | class MartinHotelNewsHandler extends XoopsObjectHandler |
||
22 | { |
||
23 | /** |
||
24 | * @get rows |
||
25 | * @license http://www.blags.org/ |
||
26 | * @created :2010年06月20日 13时09分 |
||
27 | * @copyright 1997-2010 The Martin Group |
||
28 | * @author Martin <[email protected]> |
||
29 | * @param $sql |
||
30 | * @param null $key |
||
31 | * @return array |
||
32 | */ |
||
33 | View Code Duplication | public function GetRows($sql, $key = null) |
|
48 | |||
49 | /** |
||
50 | * @get hotel news |
||
51 | * @method: |
||
52 | * @license http://www.blags.org/ |
||
53 | * @created :2010年06月29日 20时38分 |
||
54 | * @copyright 1997-2010 The Martin Group |
||
55 | * @author Martin <[email protected]> |
||
56 | * @param $artids |
||
57 | * @return array|string |
||
58 | */ |
||
59 | public function GetHotelNews($artids) |
||
82 | } |
||
83 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.