Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use primitives for null checks #4087

Open
matthias-ronge opened this issue Nov 6, 2020 · 0 comments
Open

Use primitives for null checks #4087

matthias-ronge opened this issue Nov 6, 2020 · 0 comments

Comments

@matthias-ronge
Copy link
Collaborator

In February 2019, most of the (non-) null checks in the source code were replaced by calls to the Predicate function Objects.isNull(…) or Objects.nonNull(…). This does not bring any noticeable benefit and represents an additional and unnecessary hurdle for newcomer Production programmers. While the test for == null or != null (with exactly this syntax) occurs in a variety of programming languages, a new programmer has to deal with it at least first what the object Objects is, and what the function isNull() or nonNull() does. Following Ockham's razor, they must first assume that this function does something different or something more, than the primitive test == null or != null does, otherwise the primitive would have been used. (Although this corresponds to the behavior of C++, where primitive operators can be overridden, this is often viewed as a conceptual mishap of C++ and was probably deliberately not included in the Java language specification.)

The function's Javadoc also clarifies that it only exists to be used as a Predicate.

Technically, an additional function call leads to an additional dependency and each time to an additional jump in the program flow, each time an additional entry has to be created on the stack, for no gain.

Goal: The calls to the functions Objects.isNull(…) and Objects.nonNull(…) should be reduced to the use of the primitive == null or != null again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants