Reuse, Rewrite, or Refactor?

Posted by Jon Purdy on Stack Overflow See other posts from Stack Overflow or by Jon Purdy
Published on 2010-04-14T19:28:06Z Indexed on 2010/04/14 19:33 UTC
Read the original article Hit count: 314

At work I inherited development of a PHP-based Web site after the consultant who originally produced it bailed out and left without a trace. Literally half of the code is ripped from online tutorials, and there are thousands of lines of cruft that, being incomplete, do precious little. Hardly any of it actually works. I've been trying to pull out the usable components, such as the layout (cleverly intermixed with code), session management (delicately seasoned with unescaped, unvalidated SQL queries), and a few other things, but it's very difficult to force all of this junk into place. Further, I don't speak idiomatic PHP, being more of a Perl user, and I'm supposed to be on this project principally for maintenance, so rewriting everything seems like it would take just as long as wrestling the existing monster back into place.

As an aside, I have literally never seen anything as badly written as this. Welcome me to the world of working with other people's code, I guess, but I do hope it's not this common in the real world to have such gems as these:

  • // WHY IS THIS NOT WORKING
  • // I know this is bad but were going for working stuff right now...
  • // This is a PHP code outputing Javascript code outputting HTML...do not go further
  • // Not userful

I'm looking for the best advice I can get here. What would you do if you were in my position?

© Stack Overflow or respective owner

Related posts about php

Related posts about web-development