在 Java 中弃用包的最清晰方法是什么?
我正在开发一个新的代码库并将系统迁移到一个新的框架.
I'm working on a new codebase and migrating the system to a new framework.
我想弃用一些包,只是为了让其他开发人员非常清楚,这个包中的所有内容都不应再用于新的开发.
There are a number of packages that I would like to deprecate, just to make it very clear to other developers that everything inside this package should not be used anymore for new development.
表明整个软件包已被弃用的最佳方式是什么?
What is the best way to indicate that an entire package has been deprecated?
推荐答案
你自己说过:你想弃用包内部的所有东西,而不是包本身.包只不过是一个命名空间,而弃用一个命名空间会有不同的含义——比如 不要再使用这个命名空间.像 不要向该命名空间添加任何新项目.
You said it yourself: You want to deprecate everything that's inside a package, not the package itself. The package is nothing but a namespace and deprecating a namespace would have a different meaning - like don't use this namespace anymore. Like don't add any new items to that namespace.
在您的情况下,我建议您弃用不应再使用的每个类的每个公共方法(和字段).这在现代 IDE 中变得可见,并且当开发人员想要使用旧的类和方法时会收到警告.并且您可以查看您的代码并逐步对其进行重构,以消除这些类和方法的依赖关系.
In your case, I suggest you deprecate each public method (and field) of each class that shouldn't be used anymore. This becomes visible in modern IDE's and developers are warned when they want to use the old classes and methods. And you can look through your code and refactor it step by step to eliminate dependencies of those classes and methods.
相关文章