Getting into Guava

So I recently started using Netty for my applications client/server communication and I discovered I loved the idea of listenable Futures. I wondered why I didn’t know about Java being able to do this, and, sure enough, it cannot.

After some searching I realized that this is a feature provided by Guava’s concurrency tools, which got me skimming through it’s user guide. It seems awesome, but I have some concerns:

  1. I already have a decent amount of code that uses JDK concurrency. How hard will it be to migrate over?
  2. What is the risk of starting to become a “Guava programmer” so to speak? How difficult will it be to bounce back and forth between doing things the Guava way and the core Java way?
    • What potential harm could there be if, in an existing project, I write new classes with Guava classes without migrating the rest of the code over?
  3. Is there a good guide for slowly beginning to use Guava features without having to stop doing my actual job to train myself for a few days/weeks?
  4. Is there anything else I should know in advance that I haven’t already thought of?

I think the underlying issue you have is that you’re thinking of Guava as if it’s an entire framework or DSL (domain-specific language). Guava is another library like Apache Commons where it provides common abstractions, data structures and convenience methods complementary to the JDK libraries.

Answers to your questions:

  1. If your code is designed well, it shouldn’t be difficult to use Guava’s concurrency library.
  2. No risk of being a “Guava programmer”, as I mentioned, Guava is not a DSL or JVM language (like Scala/Groovy) where you will dramatically write code differently.
  3. Besides the Wiki, JavaDocs and PDFs you find on the site, you will find plenty of blog posts on using Guava. I don’t know of any books or publications that are otherwise available. It should not take you more than a few days.
  4. No.

The only exception I see to the above is that you want to use Guava’s Functional idioms and use it as an introduction to Functional Programming in Java. Then I could see a paradigm shift occurring where you will write code differently. In that case:

  1. There is a book called “Functional Programming in Java” by Dean Wampler that talks about FP pre-Java-8. There is a beta book published by PragProg that talks about FP using Java 8 features.
  2. The Guava wiki itself warns you to use Functional idioms judiciously:

    Excessive use of Guava’s functional programming idioms can lead to
    verbose, confusing, unreadable, and inefficient code. These are by far
    the most easily (and most commonly) abused parts of Guava, and when
    you go to preposterous lengths to make your code “a one-liner,” the
    Guava team weeps.

You will find from reading the above that FP (pre Java-8) can be very awkward and verbose (due to lack of first-class functions and having to use inner classes). Believe me, there is some code in our codebase that (ab)uses these idioms and the team complains about it all the time (how it is hard to read and understand), despite having no aversion to FP in general.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật