What makes code legacy?

后端 未结 21 1916
说谎
说谎 2020-12-13 02:04

I have heard many developers refer to code as \"legacy\". Most of the time it is code that has been written by someone who no longer works on the project. What is it that ma

相关标签:
21条回答
  • 2020-12-13 02:40

    I consider code "legacy" if any or all of the following conditions apply:

    • It was written using a language or methodology that is a generation behind current standards
    • The code is a complete mess with no planning or design behind it
    • It is written in outdated languages and in an outdated, non object-oriented style
    • It is difficult to find developers who know the language because it is so old

    Unlike some of the other opinions here, I've seen plenty of modern applications that work decently without unit tests. Unit testing still has not caught on with everyone. Perhaps ten years from now the next generation of programmers will look at our current applications and consider them "legacy" for not containing unit tests, just as I consider non object-oriented applications to be legacy.

    If few changes need to be made to a legacy codebase, it's better to simply leave it as-is and go with the flow. If the application needs drastic functionality changes, a GUI overhaul, and/or you can't find anyone who knows the programming language, it's time to throw away and start over. A word of warning, however: rewriting from scratch can be very time-consuming, and it's difficult to know if you've replicated all functionality. You'll probably want to have test cases and unit tests written for the legacy application and the new application.

    0 讨论(0)
  • 2020-12-13 02:43

    According to Michael Feathers, the author of the excellent Working Effectively with Legacy Code, legacy code is a code which has no tests. When there is no way to know what breaks when this code changes.

    The main thing that distinguishes legacy code from non-legacy code is tests, or rather a lack of tests. We can get a sense of this with a little thought experiment: how easy would it be to modify your code base if it could bite back, if it could tell you when you made a mistake? It would be pretty easy, wouldn't it? Most of the fear involved in making changes to large code bases is fear of introducing subtle bugs; fear of changing things inadvertently. With tests, you can make things better with impunity. To me, the difference is so critical, it overwhelms any other distinction. With tests, you can make things better. Without them, you just don’t know whether things are getting better or worse.

    0 讨论(0)
  • 2020-12-13 02:43

    Legacy code is source code that relates to a no-longer supported or manufactured operating system or other computer technology.

    0 讨论(0)
  • 2020-12-13 02:43

    http://en.wikipedia.org/wiki/Legacy_code

    "Legacy code is source code that relates to a no-longer supported or manufactured "

    0 讨论(0)
  • 2020-12-13 02:44

    By using hardware, software, APIs, languages, technologies or features that are either no longer supported or have been superceded, typically combined with little to no possibility of ever replacing that code, instead using it til it or the system dies.

    0 讨论(0)
  • 2020-12-13 02:44

    The day you're afraid to refactor your code is the day when your code has become legacy.

    0 讨论(0)
提交回复
热议问题