Refactoring PHP, Web Services and PHP Frameworks

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Refactoring PHP, Web Services and PHP Frameworks

Post 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
PHPDevelpr
Forum Newbie
Posts: 2
Joined: Tue Sep 28, 2010 5:16 am

Re: Refactoring PHP, Web Services and PHP Frameworks

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Refactoring PHP, Web Services and PHP Frameworks

Post 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).
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Refactoring PHP, Web Services and PHP Frameworks

Post 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.
(#10850)
Post Reply