147
votes
Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?
It‘s a question of risk management:
Refactoring a system always creates the risk of breaking something that worked before.
The larger the system, the higher its complexity, and the higher the risk ...
102
votes
Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?
One reason is it's really difficult to measure the loss of productivity the messy code is causing, and difficult to estimate the work it will take to clean it properly and fix any regressions.
The ...
51
votes
Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?
It depends on your definition of "correct practice".
I'm currently working on said old spaghetti code, much of it is old enough to drink. It's a critical safety system.
Changes to this code ...
37
votes
How to analyze and understand the use/application of a "class" in a colossal million-line legacy code base?
One over riding pattern has emerged in every interaction I've ever had with technology: I learn more when it breaks.
So break it.
I mean, this is software. You can't hurt it. Sneak a copy off some ...
25
votes
Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?
I once had the joy of watching someone “refactoring” some legacy code that I had written, about two years earlier. My code was complicated, because it covered about two dozen corner cases that had ...
22
votes
Accepted
Is lack of functional requirements agile?
Whether or not lacking functional requirements is agile, it is a recipe for disaster. You cannot rebuild a system when you do not know how that system works.
You need to tell the business owner that ...
17
votes
Is lack of functional requirements agile?
Agile doesn't change the need for functional requirements, but it does generally change how you gather them. The non-agile way is for someone to go through a long process then give you some sort of ...
16
votes
Accepted
How to deal with a large codebase with no requirements and the responsible person leaving the company soon
I have ported several older VB6 applications to the .NET framework, all of them with almost no documentation, from that experience I can I give you some recommendations. First, let me say, getting rid ...
15
votes
Accepted
C#: Refactoring an oversized try/catch/finally
You could consider introducing a IDisposable-object to own whatever resource that needs cleanup, with a using statement or declaration to ensure cleanup. If each resource is in its own disposable ...
13
votes
Accepted
How to analyze and understand the use/application of a "class" in a colossal million-line legacy code base?
First, you need a goal when analyzing a class. If you don't have this, you have no idea when to stop. And with a million-line codebase, you could go on forever. Since we don't often read code for the ...
12
votes
Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?
How do you define 'correct'?
I have seen more disasters when people tried to fix something that was not broke by fixing spaghetti code.
There are times when you will be forced to make changes.
Some ...
10
votes
Accepted
Variable renaming throughout solution will produce lots of noise in git blame. What to do?
I disagree that this is a counter-argument.
blame shows who last modified lines of code, not why or to what extent. That is a structural, unfixable weakness in blame, and everyone who uses it needs to ...
10
votes
What is a good way to support multiple units (metric and imperial) for a legacy system which supports one only
Actually, keeping values in one unit and converting them at some interface would be an easier and most likely less risky solution. I would question and address the accuracy concerns. Are they just gut ...
10
votes
How to analyze and understand the use/application of a "class" in a colossal million-line legacy code base?
If it is available, look at the history of commits related to the class in your version control system (CVS, SVN, git, mercurial...). Commit messages might help. Context of commits (ie other commits ...
10
votes
C#: Refactoring an oversized try/catch/finally
I haven't used C# so this is general advice...
I would start with some simple method extractions, so your code looks something like this:
ctxBefore = doStuffBeforeLock()
if (ctxBefore.isAbort())
...
9
votes
Accepted
How do I write unit tests for legacy code (that I don't understand)?
To a first approximation, the stakeholders of a test suite are the code developers/maintainers. You're going to need some of their time. Insist on this.
Ask them about problems they're facing.
Ask ...
8
votes
Refactoring for loop (clean code aspect)
Of course it's not optimal from a performance point of view. Very few solutions are optimal, and even if they are it would be hard to prove it.
But clean code isn't about optimal ratings on any ...
7
votes
Accepted
Won't a characterization/regression test fail when a bug is fixed?
Won't a characterization/regression test fail when a bug is fixed?
Yes, usually.
So what is the appropiate course of action here? Can I just remove/uncomment the test?
"It depends".
You ...
7
votes
Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?
You need a reason to be changing any code. That reason may be as simple as dead code (unreachable), making it easier to read (loops to LINQ for instance) or as complex as refactoring multiple modules ...
5
votes
Variable renaming throughout solution will produce lots of noise in git blame. What to do?
One option is to apply the changes you describe and live with a noisy git blame for a while, because, presumably, after some time it will become less noisy.
Another is to apply these changes over ...
5
votes
How to deal with a large codebase with no requirements and the responsible person leaving the company soon
Don't.
While a rewrite due to "outdated technology" may seem like a good idea, it is not!
Every year, a new and cool technology arrives. Few years later, everyone considers it outdated.
Do you want ...
5
votes
How to deal with a large codebase with no requirements and the responsible person leaving the company soon
Try to find out why they want a rewrite. Be sure to mention that a complete rewrite just to rewrite it does not make sense. It will take a long time, and it will be buggy. Also point out that most ...
5
votes
How to approach this legacy Java project?
Do not refactor.
"done the right way" is just ass covering and not yours!
Get clear requirements and implement them with the minimum number of code changes.
Get sign off that the app works and the ...
5
votes
How to determine if a module within an application is worth refactoring or rewriting?
The rule, if there were one that made sense, would not be different for modules than for any other unit of code. After all every piece of code is a module, that is just semantics and perspective.
In ...
5
votes
Is Exception caught in the Service class a matter of preference?
Is this a matter of preference to handle errors on the DAO or service level?
No, it is not a matter of preference, because the DAO level will probably not even know about the service's LOG, so it ...
4
votes
Accepted
Follow Up: Legacy code maintenance and moving forward (implementing previous answers)
With the assumption that your team and management are on board to untangle the mess of the application, the most pragmatic answer is:
Change something and see what breaks.... then roll back
There's ...
4
votes
How to deal with a large codebase with no requirements and the responsible person leaving the company soon
Good luck.
The first thing to clarify with your boss is the time frame involved. Rewriting 250,000 lines of code will take you years. Do they understand this? But then there seem to be things in ...
4
votes
How to prepare test case for System Migration of legacy system while existing functionality is unclear?
In order to answer your last question ("how should I prepare test case in order to ensure the quality of the system?") you must answer your first two questions:
There are some differences in ...
4
votes
Is lack of functional requirements agile?
Capturing requirements is an essential part of any (successful) software project. But writing a requirements specification isn't.
A documentation-centric approach can end up like a game of Chinese ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
legacy-code × 79refactoring × 20
unit-testing × 13
testing × 8
development-process × 8
documentation × 6
maintenance × 5
legacy × 5
design × 4
java × 4
c# × 4
design-patterns × 4
php × 4
project-management × 4
rewrite × 4
c++ × 3
object-oriented-design × 3
terminology × 3
tdd × 3
integration-tests × 3
migration × 3
object-oriented × 2
domain-driven-design × 2
web-development × 2
api-design × 2