2 ms·
Rewrite are bad, true. But sometimes unavoidable. Really. When you have a PHP project where there's a mix of procedural function (the code is at the top and th
by ldng 14y ago
Rewrite are bad, true. But sometimes unavoidable. Really.
When you have a PHP project where there's a mix of procedural function (the code is at the top and the html at the bottom, so it's easy to split right ? Hum and those includes, what do they do exactly ?), ... classes (We used classes to put our functions in so we do OOP, right ? Err... no) and parts of a heavily customized Wordpress.
Plus two-three half started in-code reorg/rewrite that went nowhere because the devs jumped the ship.
You're told you have to I18N the whole spaghetti meatball soup. You try a few weeks and then see you're going nowhere and start to realize that you're doomed to a rewrite. Oh, and you're a team of two. Sometimes you really have to. And migrating data .... such a pain in the ass ! Test encoding I'm looking at you ! At of hand int code (would not call that enum) I'm looking at you too.
But. It's not always the case. And right now I'm starting the reorganize and refactoring a project that was already in a descent shape. And it's much more interesting, less straining and business owner have more visibility on the work done and are happier.
So yes, whenever you can, incremental rewrite is the way to go. But never say never. There are contexts where doing a rewrite is just plain necessary because the code is in such a bad shape you just can't add any feature anymore.
- purephase 14y agoVoted you up because you basically just described the situation I'm in now. While successfully in production, the web servers were crashing multiple times a day (still Apache-modphp). So, I started to work on the PHP upgrade from 4-5 to get onto php-fpm + Nginx to stabilize the site. Lo and behold, the legacy db abstraction code (poor man's ORM) was not playing well with later PHP releases so I started down the path to patch what I could. I successfully upgraded PHP, fixed a few of their outstanding issues, but I was weeks into this project and had not completed any of the new feature sets on my plate yet. Looking into the horizon I imagined months of wrestling with legacy code and the deeper I went (there was a SOAP layer I hadn't even looked at yet, they wanted REST/JSON) the more worried I became. We evaluated a bunch of options and opted for a re-write. We're still deep into it but there is light at the end of the tunnel and I'm pretty sure it will be worth it in the end.