Refactoring: rename class/method/variable
This refactoring is such a simple idea and you'll find yourself continually doing this as you work and build extra functionality into your web applications. There is also continual need to do this whole debugging and/or refactoring existing code.
Take for example the below class:
class person {
public $w;
function clchrlypr() {
// calculate hourly pay rate of employee
...
return $var;
}
}
Now let's look at the below example:
class employee {
private $wage;
public function calculateHourlyPayRate() {
// do some magic
}
}
Which was easier to read and follow? I would hope the second snippet was clearer, however the first is an all to common sight in some projects and seeing this code makes you really have to think hard, and quite frankly wastes time if we had written the second block of code in. The first place things would have been so much easier for our colleague.
Comments
Post a Comment