Live data from Hacker News

Ask HN: How to tell someone you need to rewrite an entire project?

news.ycombinator.com

11–20 of 25 posts

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#12
post #8

Also, be very, very sure that a rewrite is the right thing to do. Probably 80-90% of the time, it isn't, and you'd be much better off with an incremental refactor. One major way to tell: can you clearly specify what the revised version should be doing, in a way that doesn't involve "whatever the old version did"? Another litmus test: do you fully understand the old code and why it sucks the way that it does?

An incremental refactor is a possibility too, but almost everything must be refactored.

It's usually better to do things incrementally, even if the whole thing eventually needs to be rewritten and doing it incrementally takes twice as just rewriting from scratch.

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#13

Send them this article: http://www.joelonsoftware.com/articles/fog0000000069.html Then, send it to yourself.

There are legitimate reasons for a full rewrite.

If, for instance, you can change the platform and do the rewrite significantly faster than the original technology and implement changes faster, then the rewrite may be the may to go.

Imagine you have an app built on J2EE, with lots of logic on templates and no tests whatsoever. It's huge and maintaining it takes a huge effort. Every bug takes weeks to fix and generates wrong data that has to be corrected manually.

Imagine you can write an equivalent app in Ruby on Rails in two weeks, with tests.

Which way would you go?

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#14
post #4

The way I would approach it is, to create a really simple table which, contains the pros of fixing the current code on one side and doing a rewrite on the other. Then I would provide the benefits of doing both and then I'd present this to the person and say having, looked at our current code I believe that we should rewrite it because of X, Y and Z, in fact I'd even summarize this at the bottom of the table as well i…

I guess I'll try that. The code is poorly written and with possible bugs in it, so I can show a lot of problems to prove my point.

Code that is working and in use is worth roughly 10x your imaginary code that doesnt exist. So unless you could prove to me that the savings or value is 10X the cost to rewrite I wouldnt do it.

Can you be more specific about why the code is bad? There are a limited set of architectural reasons for which I would support a complete rewrite. They typically correspond to non-functional requirements: 1) scale - the system architecture simply cannot support scaling 2) reliability - the system architecture is built in such a way that the system often fails 3) multi language - the system needs to be modified to support multiple languages 4) security - the system needs to be modified to support a more robust security access model etc (there are many items like this)

These things all touch every single bit of code and so could warrant a rewrite. Im skeptical of most other reasons. In most cases you can just modularize the most dangerous aspects and you will be fine.

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#15
It always depends on the circumstances. If people don't like the term rewrite, you can just call it re-factoring or adding unit testing. You are probably using something from the old codebase, right. If anyone asks why something that used to work is no longer there, you can explain that you found bugs, and so you temporarily took it out to add more testing.

Although, rewriting can be a lot of work. While there may be a temptation to rewrite everything overnight, it can be quite difficult to pull off. Although, I think devoting some time to a rewrite attempt may help you gauge the total time it will actually take. If it proves easy enough, you can go for it.

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#16
I wonder, and this is not an insult, how much experience you have as a developer. I know that for a good five years, maybe more, as a developer in corporate IT I frequently thought that I was dealing with a "very bad" codebase and rewriting seemed like an easier task than trying to understand the current system well enough to make the changes I needed to make.

I was wrong. Every time. Unless the system is quite small and single-purpose, you very likely don't understand the full scope of what it does, why it is written the way it is, which constituencies it serves, all of its interfaces, etc.

The few times I have been involved in rewrites they always took longer than expected, cost more than planned, and ended up with kludgy patches at the last minute as features of the old system that nobody talked about or knew existed suddenly became showstopper must-have requirements. In other words, they turned out like almost any other corporate IT project.

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#17
post #4

Earlier quoted context omitted.

I guess I'll try that. The code is poorly written and with possible bugs in it, so I can show a lot of problems to prove my point.

Code that is working and in use is worth roughly 10x your imaginary code that doesnt exist. So unless you could prove to me that the savings or value is 10X the cost to rewrite I wouldnt do it. Can you be more specific about why the code is bad? There are a limited set of architectural reasons for which I would support a complete rewrite. They typically correspond to non-functional requirements: 1) scale - the system…

One of the major problems within this project are poorly written, slow db queries, MVC is not correctly implemented (although using an MVC-based Framework, function names not intuitive. I can improve, refractor some aspects of the code, but the time that will took to fix it can be more than the time to recreate it in another framework. What do you think?

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#18
I'm just going to attempt to answer your question rather than question your motives.

This is the difference between software and most other forms of "construction." There are no material costs. There is no scrap to reclaim. Bits can't be reused like steel. Tearing down code is negative work. This is also goes toward the odd feeling we often have that software shares so many attributes the fine arts even though it shares so many attributes with engineering disciplines.

First: realize that the word rewrite, not the act, strikes fear into the hearts of people. Just don't say it.

Second: realize that the difference between a "fix" and "rewrite" is nil. Are you going to fix it without changing it? Not if the problem is really in the code. You don't edit out the plot hole in your novel or unpaint your landscape into a lounging nude.

Now, the answer: say you'll fix it. You're really talking about the same thing. You asserted that it would be cost-effective and efficient. To me, that implies that it will address the urgency.

It's almost always quick and easy to fix what you know is wrong. The part that makes it hard, slow, and expensive is rolling it out. For instance, it may have taken a week to design a better data model for your SaaS app vs. a month to try to find and mitigate a slow query, but now you have to figure out how to migrate all of your clients, and that's a bitch.

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#19

Earlier quoted context omitted.

Code that is working and in use is worth roughly 10x your imaginary code that doesnt exist. So unless you could prove to me that the savings or value is 10X the cost to rewrite I wouldnt do it. Can you be more specific about why the code is bad? There are a limited set of architectural reasons for which I would support a complete rewrite. They typically correspond to non-functional requirements: 1) scale - the system…

One of the major problems within this project are poorly written, slow db queries, MVC is not correctly implemented (although using an MVC-based Framework, function names not intuitive. I can improve, refractor some aspects of the code, but the time that will took to fix it can be more than the time to recreate it in another framework. What do you think?

for me the question is still, what problems is this causing? slow db queries can easily be isolated and unless they have done something like every write to the database creates an object which then gets converted to a sql transaction, function names can be fixed with global search and replace. Not sure what you mean by MVC is not correctly implemented

Re: Ask HN: How to tell someone you need to rewrite an entire project?

#20
post #8

Earlier quoted context omitted.

An incremental refactor is a possibility too, but almost everything must be refactored.

It's usually better to do things incrementally, even if the whole thing eventually needs to be rewritten and doing it incrementally takes twice as just rewriting from scratch.

Unless the project is really very small, this is always the case with very few exceptions.

Mind you, refactoring can happen at a fairly high level -- if you identify the worst, most broken part of the code and first lock down/simplify its interfaces, you can write a drop-in replacement for that whole chunk. Just remember that if writing your drop-in replacement is going to take weeks (rather than days)... or if your estimate keeps sliding..., you've probably chosen too large a chunk and should slice & dice a bit more.

I've had this discussion so many times that now I just have it with myself, and generally only say aloud the correct answer (though it's disappointing).

Psychologically, it's a beautiful thing to wipe the slate clean and just do everything fresh from the start. If only this worked as planned more often (and budgets were hefty enough to support "doing it right", and there were not already a user base who actually wanted to keep some of the broken bits because they knew how to use them already, and you didn't have to deal with a few team members who seemed to always be writing more code just like the old stuff, etc etc)...

Post reply on HN