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 GetTopicAttributeRequest extends BaseRequest |
||
7 | { |
||
8 | private $topicName; |
||
9 | |||
10 | public function __construct($topicName) |
||
11 | { |
||
12 | parent::__construct('get', 'topics/' . $topicName); |
||
13 | |||
14 | $this->topicName = $topicName; |
||
15 | } |
||
16 | |||
17 | public function getTopicName() |
||
18 | { |
||
19 | return $this->topicName; |
||
20 | } |
||
21 | |||
22 | public function generateBody() |
||
23 | { |
||
24 | return NULL; |
||
25 | } |
||
26 | |||
27 | public function generateQueryString() |
||
28 | { |
||
29 | return NULL; |
||
30 | } |
||
31 | } |
||
32 | ?> |
||
33 |