Forget Guava: 5 Google Libraries Java Developers Should Know
Forget Guava: 5 Google Libraries Java Developers Should Know
Published on 2016 7 13
If we would stop someone during an intense hackathon and ask her to name a popular and ask her to name a popular Google Java library, the answer would probably be Guava. It’s no wonder, since its main focus is improving developer productivity. But what about other Google libraries? Have you had a chance to check them out?
What are some of the most useful yet unknown Google Java libraries?
If we would stop someone during an intense hackathon and ask her to name a popular and ask her to name a popular Google Java library, the answer would probably be Guava. It’s no wonder, since its main focus is improving developer productivity. But what about other Google libraries? Have you had a chance to check them out?
In the following post we’ll go over some interesting Java libraries from Google, and give you a peek as to what you can do with them.
Adding Another Library to the Mix
First, let’s be clear: we love Guava. It contains some of Google’s core libraries for Java based projects, such as collections, caching, common annotations, I/O, and others. These are useful not just for Google developers, but for the wider community as well as well.
Although it’s not the only cool thing that came out of Google. We’re not talking about driverless cars, Google fiber or project Ara (and we’re still waiting for that last one) – we’re talking about more libraries.
The good news is that there’s no need to comb through every available library in order to find the right one, since we did that for you. We chose 5 Google libraries that could make your life easier and code a little bit nicer. Check them out:
1. Dependency Injection – Guice
Guice is a lightweight dependency injection (DI) framework for Java, performing a similar role to Spring’s core Inversion of Control (IOC) library. It’s almost as popular as Guava. If you’re not familiar with it, Guice eases the need for factories and simplifies the use of ‘new’ in your code. In Google’s own words, Guice @Inject is the new new.
While this library won’t absolve you from writing factories, it will help make sure your code is not directly dependent on them. That way, it will be easier to change, unit test and reuse your code.
The Cool Factor
This library aims to make development and debugging easier and faster. The documentation even claims to help you get a better understanding of your code. Another cool feature Guice offers is generating helpful messages when errors occur, so you’ll have an idea of what happened and how you can solve it.
2. Static Analysis – Error Prone
This open sourced library is a static analysis tool for Java, allowing you to catch common programming mistakes at compile-time. You can be the best developer in your team, but you or one of your colleagues might be pre-occupied by the latest Game of Thrones episode, and make a mistake.
In other words, this tool will help you catch mistakes before they become bugs in production and mess up your application.
For example, one of the bug patterns it can detect is CannotMockFinalClass – which indicates that Mockito cannot mock final classes:
The Cool Factor
On the official library page you’ll find a list of common errors and their suggested fixes. This means that each error has a solution that someone already thought of, and you can implement it easily in your own code. By the way, if you’re interested in common production errors, check out our analysis on the top 10 exception types in production.
3. Meaningful Errors – Truth
Truth is a testing framework, made to help your test and error messages be more readable and discoverable. It generate meaningful error messages that report on why tests fail, while being extensible to new types of objects. Oh, and it comes with the awesome catch phrase “We’ve made failure a strategy”.
You can use Truth in place of JUnit’s assertions, FEST, or Hamcrest’s matchers classes, or simply use it the way you see fit for your code. It presents you with a test verb that asserts on a subject, the value or object under test.
You can use Truth in order to declare JUnit-style assumptions (and skip test on failure), assertions and exceptions.
4. Language-Agnostic Protocols – Kythe
Kythe provides and supports tools and standards to encourage interoperability (sharing, exchanging and using information between systems) among programs that manipulate source code. An easier way to explain it is to say that this library gives an ecosystem for building tools that work with source code.
The main goal of this library is to provide a standard, language-agnostic interchange mechanism, that will work on any source code. It includes build systems, compilers, interpreters, static analyses, editors, code-review applications and more. That way, you’ll be able to share information with any other system you’d like.
The Cool Factor
Kythe comes with a rich community that will answer any question you have. Need help with Kythe on Python, JavaScript or Java? Want to know how to model Python modules? Or do you simply want to know how to pronounce Kythe? Just ask the community.
5. Serializing Structured Data – Protobuf
Protobuf, the library that’s also known as Protocol Buffers is Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data. If you’re not sure what it means, Google explains that it’s like XML, only smaller, faster and simpler.
If we had to choose a slogan for this library, it would probably be “structure once, use anywhere”, and that’s the best way to describe it. Once you define how you want your data to be structured, you can use special generated source code to read and write from a variety of data streams and using a variety of languages.
The Cool Factor
Full disclosure is in order here: protobuf is one of our favorite libraries here at Takipi, and we can guarantee it will help you make complicated elements a little bit easier.
Did We Forget Anyone?
We know what you’re thinking – so many libraries and not a single word about GWT. GWT is a development toolkit for browser-based applications, enabling the creation of high-performance web apps even if JavaScript is not your strong suit. It’s basically a Java to JavaScript compiler.
This free, open sourced library became popular due to the many Google products that used it. That list included Google Inbox, AdWords, AdSense, Flights, Hotel Finder, Offers, Wallet and Blogger, all very known and powerful products that came out of Google.
There are a few well known companies besides Google that use GWT, such as Ruxit, Go Grid, Whirled and others.
Additional Google Libraries
Following a comment on twitter we’ve decided to add 2 more useful libraries that weren’t mentioned here, thanks @joschi83!
AutoValue – A collection of code generators that automate the generation of repetitive Java code.
GSON – The popular Java serialization/deserialization library that can convert Java Objects into JSON and back.
Final Thoughts
There are a lot of Java libraries that can help your code and make it smarter and easier to use. All you have to do is understand what you’re looking for, and see how a certain library can help.
If you’re a hardcore Guava fan and couldn’t find anything useful in these other libraries, you should check out some of the lesser known features of Google Guava that every developer could use.
Forget Guava: 5 Google Libraries Java Developers Should Know的更多相关文章
- 使用 Google Guava 美化你的 Java 代码
文章转载自:http://my.oschina.net/leejun2005/blog/172328 目录:[ - ] 1-使用 GOOGLE COLLECTIONS,GUAVA,STATIC IMP ...
- Google的java工具类Guava
前言 google开发java项目肯定也不想重复造轮子,所以肯定也有工具类,就是它了:Guava 我将举例几个实际的例子,发挥这个工具类好用的功能.更多的方法和功能,还有内部的实现可以直接参考http ...
- Watch out for these 10 common pitfalls of experienced Java developers & architects--转
原文地址:http://zeroturnaround.com/rebellabs/watch-out-for-these-10-common-pitfalls-of-experienced-java- ...
- Top 10 Mistakes Java Developers Make--reference
This list summarizes the top 10 mistakes that Java developers frequently make. #1. Convert Array to ...
- 100 high quality blogs from java developers
This list collects 100 high quality blogs from Java developers from all over the world. Some of thes ...
- Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)--reference
(Sorry for that click-bait heading. Couldn’t resist ;-) ) We’re on a mission. To teach you SQL. But ...
- Top 10 Mistakes Java Developers Make(转)
文章列出了Java开发者最常犯的是个错误. 1.将数组转换为ArrayList 为了将数组转换为ArrayList,开发者经常会这样做: ? 1 List<String> list = A ...
- 10 Unit Testing and Automation Tools and Libraries Java Programmers Should Learn
转自:https://javarevisited.blogspot.com/2018/01/10-unit-testing-and-integration-tools-for-java-program ...
- Google的Java编程风格指南(Java编码规范)
这份文档是Google Java编程风格规范的完整定义.当且仅当一个Java源文件符合此文档中的规则, 我们才认为它符合Google的Java编程风格. 与其它的编程风格指南一样,这里所讨论的不仅仅是 ...
随机推荐
- ionic获取表单input的值的两种方法
1.参数传递法 直接在input处使用 #定义参数的name值,注意在ts中参数的类型 html页面: <ion-input type="text" placeholder= ...
- MySQL索引设计需要考虑哪些因素?
索引小知识 篇幅有限,索引的基本知识我们就不赘述了,在此,我们尝试说明其中的一个小点-----B+树与B树的区别到底是什么. InnoDB是使用B+树来实现其索引功能的.在B+树中,内节点(非叶子节点 ...
- chrome打开收藏夹的网站在新的标签页
chrome浏览器在新的标签页打开收藏夹的网址,现在设置不了,而且右键,在新标签页中打开有点烦..下面说说直接打开的方式. 方法1: 鼠标滚轮,直接点击收藏夹的网址,即可 方法2: ctrl + 鼠标 ...
- MySQL服务器的安装和配置,MySQL Workbench 8.0.12安装,MySQL的基本使用
一 MySQL服务器的安装和配置 二 MySQL Workbench 8.0.12安装 三 MySQL的基本使用 一MySQL服务器的安装和配置 MySQL是目前最为流行的开放源码的数据库,是完全网络 ...
- C# groupby 应用小技巧
这两天感冒了,导致大脑无法有效运转,一个朋友问我,groupby 怎么给list 分组,然后再将其中一个字段组合起来,恩,觉得很简单,结果才发现,自己的脑子真的是不够用了: 恩,其实是想写其他的,但是 ...
- Dijango学习_01_pycharm创建应用
一.当初在学dijango的时候,网上的教程非常的杂且多,对于؏؏☝ᖗ乛◡乛ᖘ☝؏؏我们这种初入虎门的小白来说有太多误区 (其实是大佬的操作着实对小白不太友好,原谅我个萌新..2333..) 二.pi ...
- SQLServer之添加聚集索引
聚集索引添加规则 聚集索引按下列方式实现 PRIMARY KEY 和 UNIQUE 约束 在创建 PRIMARY KEY 约束时,如果不存在该表的聚集索引且未指定唯一非聚集索引,则将自动对一列或多列创 ...
- Redis学习笔记(4)——Redis五大数据结构介绍以及应用场景
出处:https://www.jianshu.com/p/f09480c05e42 Redis是典型的Key-Value类型数据库,Key为字符类型,Value的类型常用的为五种类型:String.H ...
- top后台执行显示:top: failed tty get 错误
通过其他程序或脚本在非交互式模式下调用top命令,经常会出现: top: failed tty get 错误 解决办法:加个-b 选项皆可 -b : Batch mode operation ...
- centos7下kubernetes(18。kubernetes-健康检查)
自愈能力是容器的重要特性.自愈的默认方式是自动重启发生故障的容器. 用户还可以通过liveness和readiness探测机制设置更精细的健康检查,进而实现: 1.零停机部署 2.避免部署无效的镜像 ...