处理代码中大量未使用或已弃用的功能实现的好方法

发布于 2024-10-08 06:44:18 字数 518 浏览 0 评论 0原文

目前,我们的应用程序面临以下问题:

应用程序中大约 40% 的代码从未使用过。这意味着代码会在那里,并且可能起作用,但是前端功能已关闭,因此用户无法再使用该功能,或者其他方法正在取代现已弃用的旧方法< /强>。

我目前正在做的是删除所有旧代码,同时不尝试手动破坏任何内容。

问题是:

  • 您是否会删除旧代码,或者希望它可能会在某个时候醒来......僵尸 - 就像
  • 您认为值得付出努力来删除代码(减少在混乱中查找内容的工作,更好的测试覆盖率,其他人更容易找到他们的方式)
  • 我们是否应该将准则保留在某个地方作为参考? (我们正在使用版本控制,但我发现很难在修订丛林中找到旧代码......对此有什么建议吗?)
  • 您是否有说服编写上述代码的团队/管理/开发人员的论据?
  • 不弃用然后删除代码的原因是什么?

TL;DR:删除未使用的代码还是保持原样?讨论!

Currently we are facing following Problem in our Application:

Around 40 % of the Code that is in the Application is never used. That means the Code would be there, and maybe functional, but the Frontend Feature has been shut off so the Users cannot reach the Functionality anymore or other Methods are replacing the old, now deprecated Methods.

What i am currently doing is removing all the old code while not trying to break anything, manually.

The Question is:

  • Would you remove the old Code, or hope that it may awake some time ... zombie - like
  • Do you think that it is worth the Effort to remove the Code (less work to find stuff in the clutter, better test coverage, easier for other people to find their way)
  • Should we keep the Code somewhere, as a reference? ( We are using Version Control, but i find it is pretty hard to find old code in the Revision Jungle ... any tips for that? )
  • Do you have arguments for convincing the team / management / developers that wrote said code?
  • Reasons to not deprecate and then delete Code?

TL;DR: Delete unused code or leave it as it is? Discuss!

u

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

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

发布评论

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

评论(2

小清晰的声音 2024-10-15 06:44:18

如果您确定该代码未被使用,请务必将其删除。我假设您有版本控制系统,因此如果您再次需要它,您仍然可以找到代码。

删除未使用的代码将使项目更易于维护,从长远来看,您的团队可能最终会节省时间(没有人会重新阅读代码来尝试理解它的用途,没有人最终会更改所述代码认为它可能仍然会被使用...)

但是,如果您的代码包含分布式的公共 API,您可能需要在有效删除代码之前将类/方法标记为已弃用一段时间,以便调用者有一些时间适应(或通知您该问题)。

If you are certain that the code is unused, definitely delete it. I assume you have a version control system, so if you ever need it again, you can still find the code back.

Deleting the unused code will make the project easier to maintain, and your team probably will end up saving time in the long run (nobody will re-read the code to try and understand what it was used for, nobody will end up changing said code thinking it may still be used...)

However, if your code contains a public API that is distributed, you will probably want to mark the classes/methods deprecated for some time before effectively deleting the code, so the callers have some time to adapt (or inform you of the issue).

↘人皮目录ツ 2024-10-15 06:44:18
  • 你会删除旧的代码,还是希望它能在某个时候醒来......僵尸 - 就像

我肯定会删除它一样。我讨厌必须弄清楚函数是否被调用。

  • 您认为删除代码值得吗(减少在混乱中查找内容的工作,更好的测试覆盖率,其他人更容易找到他们的方法)

是的,绝对值得付出努力。

  • 我们是否应该将《准则》保存在某个地方作为参考?

嗯,你正在使用版本控制软件,不是吗?

  • Would you remove the old Code, or hope that it may awake some time ... zombie - like

I'd definitely remove it. I hate having to work out if functions ever get called.

  • Do you think that it is worth the Effort to remove the Code (less work to find stuff in the clutter, better test coverage, easier for other people to find their way)

Yes, definitely worth the effort.

  • Should we keep the Code somewhere, as a reference?

Um, you are using version control softwarev, aren't you?

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