TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Engineering NullAway, Uber’s Open Source Tool for Android NullPointerExceptions

4 点作者 myhrvold超过 7 年前

1 comment

gregjor超过 7 年前
I think something is wrong with the code if null pointers are a big problem in a Java code base.<p>The example in the article shows a class with an exposed nullable member, and a function outside of the class referencing the possibly null member. I know it&#x27;s an example but it&#x27;s a bad practice to expose class variables like that. The only code that should have to check for a null member should be in the class, not scattered all over the code base. The example in the article shows a function referencing a member of a member (x.f). This just looks like very bad OO design and implementation to me.<p>Another approach is to never have null members. Use placeholder objects that have the expected interface but do something reasonable, like logging or reporting the error when referenced. That&#x27;s better than crashing.<p>As an Uber user and programmer I&#x27;m wondering how the Uber mobile client is so complex that the code has so many problems like this that you need to write special tools just to detect them.