Ask HN: Rewrite outsourced code or refactor it?
The app isn't super complex (yet) because they were waiting to add most of the complexity once they could get a proper dev team. The code is a mess though, here are some things:
- Inline SQL statements
- Inline PHP inside of on-page javascript
- Pages aren't even W3C validated (or even close!)
- No tests at all
- No data modeling whatsoever
- Tons of PHP related inconsistencies in the data int 0 is false - obviously.
- And much more!
Our choices are:
- Continue in PHP and try to refactor
- Switch to python with Django or something and do a full rewrite.
Underlying db is MySQL. Currently, I'm the only developer but we're looking for more. However, if we do decide to rewrite I'd look for the python variety - otherwise I'd go down the PHP road. (I'm comfortable in both, worked with both in production)
HN Gurus, what are your opinions on refactoring vs. rewriting such a code base ? Everywhere I look people say "Do not rewrite, you'll kill yourself" but almost every time the condition of the code doesn't seem quite like this.. at-least not in the way it's described.
3 comments
[ 3.3 ms ] story [ 15.7 ms ] threadThe "Do not rewrite, you'll kill yourself" advice only applies when the code has history. Legacy code has actual users that expect it to work a certain way, and has been tweaked over the years to cover cases that you aren't thinking about when you first start a project.
Your code isn't that. Your code is a prototype that you should feel fine about throwing away.
I wouldn't say that the code is a prototype but it sure is an MVP. There are tons of issues with it and one thing about refactoring that scares me is that we may not necessarily hit all the buggy corners of it and may end up with some corrupt data.