at Pagar.me (Sao Paulo, Brazil). ~8 years PHP and (now struggling with) Node.js. Refactor enthusiast (mending is awesome!). I love dogs/cats/a bunch of other stuff!
descriptive declaration. Be explicit as possible. In critical situations, you can insert the new call inside the old one; so you can keep changing without breaking any compatibility in your code base.
Foo { public function oldScaryMethod( $foo, $bar, $baz ) { // Lots of things happening here } } // Call encapsulated in another method class Foo { public function newMethod( $foo ) { // We can act here $this->oldScaryMethod(...); } public function oldScaryMethod(...) { // Complexity is now isolated! } }
seek and destroy. Don’t be affraid to delete code - use your VCS and relax. Remember to always have a good test strategy to make sure that things aren’t left broken.
Encourage your team by cultivating a good culture of refactoring, involving tests, boldness, and empowerment. Don’t be negligent: the problem you neglect today will become the bug you will fix tomorrow - or 10 minutes after deploying.