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 |
||
34 | class DNDataTransfer extends DataObject { |
||
35 | |||
36 | private static $db = array( |
||
37 | "ResqueToken" => "Varchar(255)", |
||
38 | // Observe that this is not the same as Resque status, since ResqueStatus is not persistent. |
||
39 | "Status" => "Enum('Queued, Started, Finished, Failed, n/a', 'n/a')", |
||
40 | "Direction" => "Enum('get, push', 'get')", |
||
41 | "Mode" => "Enum('all, assets, db', '')", |
||
42 | "Origin" => "Enum('EnvironmentTransfer,ManualUpload', 'EnvironmentTransfer')", |
||
43 | "IncludeResampled" => "Boolean", |
||
44 | ); |
||
45 | |||
46 | private static $has_one = array( |
||
|
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.