Page 2 of 2

Re: Refactoring PHP, Web Services and PHP Frameworks

Posted: Thu Sep 30, 2010 7:20 am
by josh
There's no silver bullet or magic refactoring. Just a simple "guideline". Any "rewrite" should take less than 4 hours and be tested in an automated manner. Even with tests, if something is taking longer than 4 hours, I sit back and reflect on the time I wasted as I revert out everything I was working on. My goal is to see a complete pass on my automated tests at least every 4hrs. So a "rewrite" for me ends after 4hrs. At that point I need to either commit or revert, I have to choose one (not even a choice really, if the tests fail - I revert).

Also see: http://en.wikipedia.org/wiki/Cowboy_coding

Re: Refactoring PHP, Web Services and PHP Frameworks

Posted: Mon Oct 04, 2010 4:21 am
by PHPDevelpr
Guys,
Many thanks for the responses and the interesting debate.

I know this has been touched on and discussed, but is there more merit in completely rewriting the existing code using a structured framework like Zend or Symfony as opposed to refactoring the existing code?

Or is this a case that the existing code will have too much influence on the rewrite using a framework whereby I will end up where I began.

Any thoughts appreciated.

Thanks again for the responses.

Re: Refactoring PHP, Web Services and PHP Frameworks

Posted: Mon Oct 04, 2010 10:54 am
by josh
The answer to your question is yes. Do whatever saves you time, except not writing tests/work (tests may or may not save time, but they will save the project).

Re: Refactoring PHP, Web Services and PHP Frameworks

Posted: Mon Oct 04, 2010 6:36 pm
by Christopher
PHPDevelpr wrote:I know this has been touched on and discussed, but is there more merit in completely rewriting the existing code using a structured framework like Zend or Symfony as opposed to refactoring the existing code?
I would not try to rewrite unless you have a lot of time and resources available. You can refactor to improve any codebase -- use tests as Josh says.

If you want to port in place, I described how I have done that above.