Replacing code once it hits big?
flexterra wrote
"Use whatever you know best. This decisions tend not to be so important. If your app becomes real big you will end up replacing most of your code anyway. The most important thing is to build and launch as fast as possible."
I'm not a web developer but learning to be one. I hired a few programmers from India to prototype a v1 of a web app. If it ever becomes big, is it really possible to rewrite the codebase? Cause Isn't rewriting a site from scratch considered bad?
(
5 comments
| 7 points
| on HN
)
On the other hand, if you're about to become as big as Twitter and Facebook wrt managing users, data, latency and traffic, you'll have to do all kinds of performance optimizations throughout your entire tech stack. This might involve rewriting your code because your code is based on fundamentally flawed design decisions (hey, non-concurrent code seem like an fine idea when you started out with your batch processing but pretty soon you'll need to time travel if those nightly cronjobs are to be finished in time) or too cthulhulian to mantain anymore. But then again, 99.99999% of all sites simply don't consistently experience performance issues on the same level as Twitter or Facebook, so that's another reason why you should focus on agility and delivering value instead of performance (unless, of course, performance truly is a key feature) initially in a software project.
- It preserves all the built up knowledge encoded in your codebase, as you're never throwing away everything and starting over.
- It makes it possible to continue feature development during the refactor. Often with big ground up rewrites, it's necessary to declare a feature freeze, often for months at a time. Otherwise, the team that's doing the rewrite is constantly trying to play catch up to the newly developed features.
- It can be done gradually over time, which decreases the investment necessary to start seeing some gains.
Many people shy away from incremental refactoring when it comes to making large scale changes to a code base. They seem messy, expensive, and time consuming. And guess what? They are. But a ground up rewrite will generally be even messier, more expensive, and in the long run, more time consuming.
There are several reasons to do a re-write: 1) The technology stack has changed and implemented new features which will make future maintenance easier (or has found issues with underlying implementations in older versions).
2) Business process/site design issues have come out for which patching code will cause undo stress to the code structure.
3) Those edge cases discussed that have been added are causing severe performance issues because the customer/end user is using the system differently than expected.
4) Underlying security vulnerabilities.
Now, re-writing/re-factoring for the sake of doing it is probably a waste.
However, IF the codebase is really, really bad, or your requirements have changed a LOT, and there is little learning embedded in your code, complete rewrites may be necessary/useful.