Hacker News new | ask | show | jobs
by dkrikun 2744 days ago
There is a lot of advice here to do incremental rewrites, refactoring, unittesting, functional/system testing etc.

Undoubtfuly it is all mature and correct advise. However, I feel it is all one-sided and I ought to provide some counter points:

1. The codebase in question may be well beyond the line where any sane person would touch it, seriously.

2. Individuals experienced with the codebase, its structure, implementation, technology stack might be not available (think cobol).

3. Refactoring or incremental rewrite is a process that has to be planned and managed s.t. current product/codebase structure. Oftencase it is this very structure, which demands the full rewrite -- because of it being too convoluted to allow refactoring to take place.

4. You might want to do a rewrite to refresh the tech. stack -- language, design, frameworks -- it is ok to do so.

5. You do not necessarily need to come with the same feature set. Both you and your customers might want to cut down unnecessary cruft. Technical debt usually starts to show its signs with losing flexibility w.r.t user request to change features.

6. Occasionaly you might come up with a separate, different product, with a different name and brand -- which might turn out to be even better!

7. You learn a lot in the process.

3 comments

I think this is a pretty reasonable set of counter points, even if I don't agree with them.

Being part of team incremental rewrite, myself, I'd say that you're overestimating the cost of the incremental rewrite and underestimating the cost of the rewrite.

For your first 2 points especially, I'd argue if you can't even begin to incrementally rewrite a system, you're in no position to begin to plan a full rewrite.

It is mainly a matter of decision making. In my case, no refactoring was ever sanctioned by itself. Devs were having been allowed to refactor anything on a small scale and always backed up by a feature request. So when the desire to somehow "heal" the codebase is met, it is usually because it is already too "dead" to work with in the first place.
I'm not sure what you mean by your last sentence.

I'd say that if code is being used in production it's not yet "dead", and it should be a much higher priority for team members to work with it.

Can you not add additional tests? Refactor out even a single feature at a time into more modern tech?

> 1. The codebase in question may be well beyond the line where any sane person would touch it, seriously.

> 2. Individuals experienced with the codebase, its structure, implementation, technology stack might be not available (think cobol).

There are people that reverse engineer binaries, find a place they can use a buffer overflow to insert a jump and then “program” by jumping around to different parts of the existing compiled code.

Your legacy cobol spaghetti code isn’t impossible to understand—-get better or better motivated engineers.

> 3. Refactoring or incremental rewrite is a process that has to be planned and managed s.t. current product/codebase structure. Oftencase it is this very structure, which demands the full rewrite -- because of it being too convoluted to allow refactoring to take place.

It does take extensive, often tedious effort, but there’s no such thing as too convoluted. A giant ball of tangled string can be pulled apart one knot at a time.

> 4. You might want to do a rewrite to refresh the tech. stack -- language, design, frameworks -- it is ok to do so.

> 7. You learn a lot in the process.

It probably is very true that a rewrite is often better for the resumes of employees. But employment is a fiduciary relationship. By cashing that paycheck you’ve agreed to put the company’s interests before your own. And rewrites kill companies.

When someone new comes in and within six months of starting starts pushing for a rewrite he should be fired and a hard look should be taken at what went wrong with the hiring process.

The codebase in question may be well beyond the line where any sane person would touch it, seriously.

Sure. If you ever find this [1] a rewrite does look like the only sane decision.

[1] https://ayende.com/blog/4612/it-really-happened-legacy-progr...