过时属性的使用 [英] Usage of the Obsolete attribute

查看:163
本文介绍了过时属性的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近告知这是不好的做法,标志着haved一些在我们的code与 [作废] 属性的方法。这些方法是内部我们codeBase的,而不是在一个API。该方法处理旧的加密功能。

I was recently told it was bad practice to haved marked a number of methods in our code with the [Obsolete] attribute. These methods were internal to our codebase, rather than being on an API. The methods handled an older encryption function.

我觉得这是表示对团队,这些方法不应该使用的其余部分的快速和安全的方式,并提供了一​​个消息以提示的替代品。

I felt it was a quick and safe way to denote to the rest of the team that these methods should not be used, and provided a message to suggest alternatives.

其他人认为我应该完全删除方法,改写或重构需要现有code。此外,它被认为太容易忽略的编译器警告。

Others felt that I should have removed the methods entirely, rewriting or refactoring existing code as required. Additionally, it was thought too easy to overlook the compiler warnings.

是否有标记code作为过时的,当它不被使用由第三方一个最佳实践?或者,这很大程度上是主观的?

Is there a 'best practice' for marking code as Obsolete when it's not being used by 3rd parties? Or is this largely subjective?

推荐答案

步骤1.标记的成员或类[作废]

Step 1. Mark the member or class as [Obsolete]

步骤2.更新成员或类的所有内部使用的将是使用新办法,取代过时的做法,或标记的成员或类本身为[作废]

Step 2. Update all internal uses of the member or class to either use the new approach that replaces the obsolete approach, or mark that member or class itself as [Obsolete]

步骤3.如果你在步骤2中标注新的东西,[过时],根据需要重复此步骤。

Step 3. If you've marked new stuff as [Obsolete] in Step 2, repeat this step as needed.

步骤4.拆下所有过时的成员和类既不公开也不是由一个过时的公共成员或类使用。

Step 4. Remove all obsolete members and classes that are neither public nor used by an obsolete public member or class.

步骤5.更新文档给该办法的一个清晰的描述建议更换任何公开过时的成员或类。

Step 5. Update documentation to give a clearer description of the approach recommended to replace any public obsolete members or classes.

在本月底,你不会有任何过时的code,它仅用于内部code。还有什么可说的,你需要做的这一切一气呵成,虽然;在每个阶段你已经取得了进展。开始步骤1和结束步骤5之间的时间可以是5秒5年中,这取决于许多因素(其中大部分是与复杂性)。

At the end of this, you will have no obsolete code that is solely used by internal code. There's nothing to say that you have to do all of this in one go though; at each stage you have made progress. The time between starting step 1 and ending step 5 could be 5 seconds or 5 years, depending on many factors (most of them to do with complexity).

顺便说一下,如果有人发现了它容易被忽视的编译器警告,这个问题是不是与[过时。然而,一个理由不留在code等需要长期(即,就已经做了作为第2步ASAP)是确保人们不会最终成为使用,因为它们是编译器的警告要编译code中的习惯性反应的一部分。

Incidentally, if someone finds it easy to ignore compiler warnings, the problem is not with [Obsolete]. However, one reason not to leave such calls in the code for long (that is, to have done as far as step 2 ASAP) is to make sure people don't end up becoming used to compiler warnings as they're part of the habitual response to compiling the code.

这篇关于过时属性的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆