番石榴的最佳使用方法 [英] Best Way To Use Guava

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

问题描述

您认为使用番石榴的最佳方法是什么?因为在网站上,这些家伙说接口在发布1.0之前可能会发生变化.考虑到这一点,您编写的代码不应直接依赖于这些接口,因此,您是否将所有调用的Guava代码包装到我们项目中的某种层或外观中,以便在这些接口发生更改时,至少那些变更集中在一处了吗?

Which is the best way you think to use Guava? Since, in the web site, the guys say that the interfaces are subject to change till they release 1.0. Taking this into account, the code you write shouldn't depend directly on those interfaces, so, are you wrapping all the Guava code you call into some kind of layer or facade in our projects in order to, if those interfaces change, then you at least have those changes centralized in one place?

哪个是最好的方法?我真的对开始使用它很感兴趣,但是我有一个问题想我了哈哈:)

Which is the best way to go? I am really interested in starting using it but I have that question hitting my mind hahah :)

推荐答案

我不确定您在哪里获得有关接口在1.0版之前可能发生更改的信息. Guava的前身Google Collections确实如此,但是它已经发布了1.0版本,现在已成为Guava的一部分.此外,不会以可能破坏代码的方式更改Google收藏夹中的任何内容.

I'm not sure where you're getting that about the interfaces being subject to change until version 1.0. That was true with Google Collections, Guava's predecessor, but that has had its 1.0 release and is now a part of Guava. Additionally, nothing that was part of Google Collections will be changed in a way that could break code.

番石榴本身甚至不使用概念为"1.0"的发布系统.它只是会发布,标记为"r05","r06"等在.除非标记了 @ Beta 批注.如果@Beta在类或接口上,则该类中的任何内容都可能发生更改.如果没有为类添加注释,但有类中的某些方法,则这些特定方法可能会发生更改.

Guava itself doesn't even use a release system with a concept of "1.0". It just does releases, labeled "r05", "r06" and so on. All APIs in Guava are effectively frozen unless they are marked with the @Beta annotation. If @Beta is on a class or interface, anything in that class is subject to change. If a class isn't annotated with it, but some methods in the class are, those specific methods are subject to change.

请注意,即使使用@Beta API,它们提供的功能也很可能不会被完全删除...最多,它们最多可能只是更改提供该功能的方式.此外,我相信他们会在将其完全更改为1版本之前不赞成更改任何@Beta API的原始格式,从而让您有时间看到它已更改并更新为该API的新格式. @Beta也不表示类或方法没有经过充分测试或不适合生产使用.

Note that even with the @Beta APIs, the functionality they provide will very likely not be removed completely... at most they'll probably just change how that functionality is provided. Additionally, I believe they're deprecating the original form of any @Beta API they change for 1 release before removing it completely, giving you time to see that it's changed and update to the new form of that API. @Beta also doesn't mean that a class or method isn't well-tested or suitable for production use.

最后,如果您正在使用Guava的应用进行操作,那么这应该不是什么大问题.只要您正在使用的任何@Beta API发生更改,只要随时随地进行更改,就应该足够容易地更新到新版本.正是使用Guava编写的人确实需要避免使用@Beta API,因为使用它们可能会导致您无法在应用程序中切换到较新版本的Guava或使用的情况.另一个使用较新版本的库,因为它将破坏较旧库中依赖于已更改/删除的beta API的代码.

Finally, this shouldn't be much of an issue if you're working on an application that uses Guava. It should be easy enough to update to a new version whenever, just making changes here and there if any @Beta APIs you were using changed. It's people writing libraries that use Guava who really need to avoid using @Beta APIs, as using one could create a situation where you're unable to switch to a newer version of Guava in your application OR use another library that uses a newer version because it would break code in the older library that depends on a changed/removed beta API.

这篇关于番石榴的最佳使用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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