How to update strange apps without errors?

My new project is to update the Software that the client has been using for many years. As we all know ... things have grown over the years.

So I looked at the old application. get all information about it and write many user stories. After cleaning up, I realized that I had made (eventually) a mistake that leads to the same problem as the client's.

This is another mistake I made, but very annoying.

How do you guys prevent such errors. Are you giving up viewing the old app?

+2


source to share


5 answers


This is a really hard problem. I will describe what I would (and would) do if the old code is substantially large.

In general, the old code is full of solutions, bug fixes and undocumented actions. If you throw it away, you are bound to make many of the same mistakes they did, and then some more.

For what it's worth, you have to evolve the system around the old code. Try to abstract away old code, for example by creating interfaces, and then implement them by calling the old code first. Write a lot of unit tests for interfaces and see how old code works. New functions have to get new implementations, so old code and new code will live side-by-side, for as long as needed, and perhaps even forever.

Now, slowly and carefully break into old code, refactor it, replace it, and make sure your tests still pass. Also write new tests. If you have regression tests for the system (other than unit tests), they should still pass.

Don't touch the old code, usually if it works fine there are no bugs for it, it passes your tests and doesn't need to be extended.



Some good resources:

http://martinfowler.com/bliki/StranglerApplication.html

Working effectively with legacy code

I also found it on StackOverflow:

Strategy for large-scale refactoring

+2


source


Unit testing. But if you haven't had unit tests before, they won't help you.



0


source


This question sounds like you are modifying existing code by "cleaning it up" rather than rewriting it. This process is sometimes referred to as "Refactoring". There is a great book on refactoring called Refactoring by Martin Fowler. He starts by providing concrete examples of refactoring from the actual code and links future chapters on the specific techniques he uses alongside the code.

One of the first things he says about refactoring is to write a test to verify that the code you are changing does the same for some common set of inputs. Then, when you "refactor" the code, run a test against it to make sure it works the same way. It can be pre-bugfix or post-bugfix. But if there is a bug, of course, you have to roll it out in addition to refactoring.

0


source


Why rewrite from scratch? You may be able to reuse parts of an existing application and reorganize those parts that need to be changed.

0


source


When I am about to recreate something that has already been done, I try not to look at the already existing implementation. I try to focus on what it is supposed to accomplish, rather than looking at how it is trying to do it.

0


source







All Articles