你什么时候说代码是遗留代码?

发布于 2024-07-06 02:22:08 字数 17 浏览 6 评论 0原文

任何有用的指标都可以

Any useful metrics will be fine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

冷情妓 2024-07-13 02:22:08

我在代码中寻找的内容之一是单元测试。 这将给予重构它的自由。 因此,如果代码没有测试,我认为它是遗留代码。

One of the things that I look for in a code is unit test. This will give the freedom to refactor it. So if the code does not have tests I consider it a legacy code.

小巷里的女流氓 2024-07-13 02:22:08

如果代码:

  1. 已被实现相同或功能或更好的较新代码替换
  2. 当前系统未使用
  3. 很快将被其他内容完全替换
  4. 由于历史原因已被存档
  5. 当供应商停止支持它时,

If the code:

  1. has been replaced by newer code that implements the same or functionality or better
  2. is not being used by current systems
  3. is soon to be replaced by something else altogether
  4. has been archived for historic reasons
  5. when vendors stop supporting it
美人迟暮 2024-07-13 02:22:08

更好的问题可能是什么将一段代码标记为非遗留代码。

对我来说,遗产意味着不可改变。 因此,一旦你不再“能够”改变它,它就成了遗产。

这种能力是否因固定要求、对损坏的恐惧、知识丢失或其他一些影响而被消除,在很大程度上是无关紧要的。

一个相关的说明是,我认为我永远不会使用确切的“遗产”这个词,因为它激起了太多的情绪而没有用处。

A better question would probably be what marks a piece of code as non legacy.

To me legacy means unchangeable. So as soon as you're no longer 'able' to change it it's legacy.

Whether that ability is removed by fixed requirements, fear of breakage, knowledge loss, or some other impact is largely irrelevant.

A related note is that I don't think I'd ever use the exact word legacy as it stirs up too many emotions to be useful.

伤痕我心 2024-07-13 02:22:08

我们使用术语“遗留”来指代仍在使用的、使用我们已停止积极开发的技术开发的任何代码。

我们宁愿使用更新的工具重写这些代码,也不愿在其当前状态下进行修改。

We use the term "legacy" to refer to any code, still in use, developed using technology we have ceased active development in.

It is code that we would rather rewrite using more recent tools than modify in its current state.

我早已燃尽 2024-07-13 02:22:08

Micheal Feathers 是优秀的《有效处理遗留代码》的作者,他将遗留代码定义为任何没有测试的代码。

Micheal Feathers, Author of the excellent "Working Effectively with Legacy Code", defines it as any code that does not have tests.

心病无药医 2024-07-13 02:22:08

我不相信有一个明确的答案,但我确实相信,代码是遗留代码的可能性随着不想接触它的人数的增加而增加,并且更改它会导致它损坏的可能性也会增加。

I don't believe there is a definitive answer, but I do believe that the likelihood that code is legacy code increases with the number of people who don't want to touch it and the likelihood that changing it will cause it to break.

凉城 2024-07-13 02:22:08

“遗留代码”这个术语是主观的,并且可能是一个负载术语。 但总的来说,我同意这样的观点:遗留代码是不可单元测试的,因此很难重构。

the term "legacy code" is subjective and is probably a loaded term. but in general I subscribe to the view that legacy code is one that is not unit-testable and as such is hard to refactor.

不必你懂 2024-07-13 02:22:08
  • 当代码足够旧时,您永远不会遇到最初编写该代码的开发人员。
  • 当不再支持第三方库时。
  • When the code is old enough you never met the developer who originally wrote the code.
  • When 3rd party libraries aren't supported anymore.
半世晨晓 2024-07-13 02:22:08

在我看来,所有编写的代码都是遗留代码。 最初的意图和关于代码所做的所有决定可能需要一段时间才能被忘记,但迟早你无法想象他们在编写代码时在想什么。 您从不自己编写遗留代码,对吗?

使用单元测试或开发人员离开大楼后的秒数等度量并不能真正衡量代码是否是遗留代码。 遗留代码可能有一套良好的单元测试和注释,并且可能已经经过严格的代码审查和其他分析。 这并不意味着代码仍然与手头的程序相关。 它只是表明代码可能写得相当好。 如果它不再相关,那么代码实际上会使解决程序开发的问题变得更加困难。

In my opinion all code that is written is legacy code. It might take some time before the original intent and all the decisions made about the code is forgotten but sooner or later you cannot imagine what they were thinking while writing it. You never write legacy code yourself, right?

Using unit tests or some measure like seconds since the developer has left the building do not really measure whether or not the code is legacy code. Legacy code may have a good set of unit tests and comments and it may have undergone a strict code review and other analysis. This doesn't mean that the code is still relevant for the program at hand. It just suggests that the code might be comparably well written. And if it is no longer relevant, the code will actually make it harder to solve the problem the program is developed for.

破晓 2024-07-13 02:22:08

遗留代码在许多地方被定义为“未经测试的代码”。 我不认为它们在测试类型上是特定的,但总的来说,如果你不能在不担心发生未知事情的情况下对代码进行更改,那么它很快就会消失。

请参阅“有效使用旧代码

Legacy code has been defined in many places as "code without tests". I don't think they are specific in the types of tests, but in general, if you can't make a change to your code without the fear of something unknown happening, well, it quickly devolves.

See "Working Effectively with Legacy Code"

一刻暧昧 2024-07-13 02:22:08

我可能是错的,但我认为没有一个既定的衡量标准。

通常,当一段代码经历了至少 5-6 个发布周期(也许更多)时,它被视为遗留代码。 通常情况下,原始实现者已不再存在,而代码则由其维护。

I maybe wrong, but I don't think there is an established metric for this.

Usually a piece of code is deemed to be legacy, when it has seen at least 5-6 release cycles( maybe more ). More often than not, the Original Implementor is no longer around and the code is maintained through.

哀由 2024-07-13 02:22:08

开发人员离开场地后几乎几秒钟。 :)

如果...

银行里没有钱购买新功能,

您找不到任何人承认正在从事需要修复

源代码的项目,您拥有的项目已经消失

...那么您正在从事遗留代码。

Almost seconds after the devs leave the premises. :)

If...

there's no money in the bank for new features

you can't find anyone that admits working on the project that needs fixing

the source code to the project you own has gone MIA

...then you're working on legacy code.

谁人与我共长歌 2024-07-13 02:22:08

通常,当周围没有人熟悉或感觉维护代码时,人们将某些东西称为遗留代码。

单元测试使不熟悉代码的人更容易深入研究代码,因此理论上它有助于防止代码成为“遗留”。

Usually people refer to something as legacy code when no one is still around that is familiar with or feels comfortable maintaining the code.

Unit tests make it easier for people unfamiliar with code to dig into it, so the theory is it helps prevent code from becoming "legacy".

往事随风而去 2024-07-13 02:22:08

通常,当代码是遗留代码时,它会以不同的方式进行更改。 人们害怕改变它,但变化往往快速且肮脏,因为没有人了解全部后果。 可能会出现代码重复问题,因为人们不想承担与更深层次的更改相关的风险。

因此,在这种情况下,情况可能会以越来越快的速度变得更糟

Often when code is legacy it is changed in a different manner. People are afraid to change it, but also changes tend to be quick and dirty because nobody understands full consequences. Code duplication issues may arise, because people don't want to take the risk associated with deeper changes.

So, in such circumstances, the situation may get worse, at an increasing rate.

山川志 2024-07-13 02:22:08

我不知道有什么真正的指标可以用来确定某些东西是否是“遗留代码”,但是任何比刚刚编写的内容更旧的东西都可以被视为遗留代码。 遗留代码对于不同的人/组织来说意味着不同的事情,所以它确实有点主观。

I don't know of any real metrics that can be used to determine if something is "legacy code" or not, but anything older than just written could be considered legacy. Legacy code means different things to different people/organizations, so it really is somewhat subjective.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文