简体   繁体   English

使用番石榴的最佳方式

[英]Best Way To Use 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. 因为,在网站上,这些人说接口可能会发生变化,直到发布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? 考虑到这一点,您编写的代码不应直接依赖于这些接口,因此,您是否将所调用的所有Guava代码包装到我们的项目中的某种层或外观中,以便,如果这些接口发生更改,那么您至少将这些变化集中在一个地方?

Which is the best way to go? 哪种方式最好? I am really interested in starting using it but I have that question hitting my mind hahah :) 我真的很有兴趣开始使用它,但我有这个问题击中我的想法哈哈:)

I'm not sure where you're getting that about the interfaces being subject to change until version 1.0. 我不知道在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. 对于Guava的前身Google Collections来说,情况确实如此,但它已经发布了1.0版本,现在已成为Guava的一部分。 Additionally, nothing that was part of Google Collections will be changed in a way that could break code. 此外,任何属于Google Collections的内容都不会以可能破坏代码的方式进行更改。

Guava itself doesn't even use a release system with a concept of "1.0". Guava本身甚至不使用具有“1.0”概念的发布系统。 It just does releases , labeled "r05", "r06" and so on. 它只是发布 ,标记为“r05”,“r06”等。 All APIs in Guava are effectively frozen unless they are marked with the @Beta annotation. 除非用@Beta注释标记,否则Guava中的所有API都会被有效冻结。 If @Beta is on a class or interface, anything in that class is subject to change. 如果@Beta在类或接口上,则该类中的任何内容都可能发生变化。 If a class isn't annotated with it, but some methods in the class are, those specific methods are subject to change. 如果一个类没有用它注释,但是类中有一些方法,那些特定的方法可能会发生变化。

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. 请注意,即使使用@Beta API,它们提供的功能也很可能无法完全删除...最多它们可能只是改变了提供该功能的方式。 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. 另外,我相信他们会弃用他们在1个版本中更改的任何@Beta API的原始形式,然后完全删除它,让您有时间看到它已更改并更新到该API的新形式。 @Beta also doesn't mean that a class or method isn't well-tested or suitable for production use. @Beta也不意味着某个类或方法没有经过充分测试或适合生产使用。

Finally, this shouldn't be much of an issue if you're working on an application that uses Guava. 最后,如果您正在使用使用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. 无论何时更新到新版本都应该很容易,只要在这里和那里进行更改,如果您使用的任何@Beta API都已更改。 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. 是人们编写使用Guava的 ,他们确实需要避免使用@Beta API,因为使用它可能会导致您无法在应用程序中切换到较新版本的Guava或使用另一个使用较新版本的库,因为它会破坏旧库中依赖于已更改/删除的beta API的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM