"It works - do not touch." Should I break the rules?

    Introduction


    There was very little opportunity to introduce users into the context before voting. Thanks! So

    Preamble


    When working with old legacy code, sometimes there are quite problematic areas that there is a desire to rewrite / fix / redo, but there is no such possibility. This code may be with errors that have not been fixed for years and have to be put up with. What to do with such code?

    There are all sorts of problems. Starting from problems with readability \ logic, ending with real errors, memory leaks, deadlocks.

    They try not to fundamentally change such code; only local problems and errors are fixed. The rule "works - do not touch" in all its glory. On the other hand, if you rewrite or correct this code, then life will become easier for everyone, but problems appear:
    • No one understands how changes will affect the entire system as a whole;
    • The probability of making new mistakes is very high;
    • A period of code stabilization appears (as with the new code).


    I hold the position that the code must be constantly developed and improved. To transfer the old sections to the rails of new technologies as soon as this becomes necessary. That is, if there is a problem or need, then you need to fix the code, and not study the workarounds (idealizing, often backward compatibility is a limitation). Of course, instability appears in the system for some time, caused by the possible introduction of errors, but for this there is continuous integration, testing, release of versions.

    One of many examples.


    HTML is formed in the code by calling someone printf. What does it have to do with a wild mixture of flag logic "if such a flag is set and this number is greater than 1234, then we deduce ...". It also displays javascript based on the same flags. For many years, it has been TODO's “Get Rid of This Nightmare Logic”, but no one is fixing this site. It turns out that it forms not quite correct HTML and you need to add new logic, somewhere in the middle of this section.

    Only registered users can participate in the survey. Please come in.

    What are you doing with this code?

    • 17.6% We don’t touch, it works 263
    • 23.8% Ruthlessly Eradicate 356
    • 54.4% We make changes when necessary 812
    • 4% We do not have outdated code 61

    Also popular now: