News for hackers. Stuff that matters.
Re:Add detailed message to NullPointerException describing w... by hamandcheese on Tuesday March 26, 2019 @01:06PM (#19493755)
It’s a code smell if you are calling a method chain that long at all.
Re:Add detailed message to NullPointerException describing w... by AaronFriel on Tuesday March 26, 2019 @01:55PM (#19494352)
This is largely not the case outside of the C-like languages that inherited nulls.

Long method chains with a strong type system or a functional (also called "fluent") style are extremely expressive and common in languages that obviate the need to handle null values at every member.

Re:Add detailed message to NullPointerException describing w... by hamandcheese on Wednesday March 27, 2019 @05:07AM (#19499112)
Regardless of safety guarantees (or lack thereof), a method chain that long indicates a lot of knowledge of the structure and hierarchy of the dependency. It makes refactoring/testing/mocking more difficult.
Re:Add detailed message to NullPointerException describing w... by fgonzag on Thursday April 04, 2019 @08:10PM (#19578407)
What does the length of the method chain have to with anything? Let's say I define an interface Foo.bar.xyz with method call, and I call the implementation foo.bar.xyzimpl.method()

Everything is just as testable and decoupled, it's just a different project structure.

Method chains have nothing to do with the things you stated.

Re:Add detailed message to NullPointerException describing w... by int_19h on Tuesday March 26, 2019 @02:27PM (#19494648)
It's usually a property chain, not a method chain - I don't think get...() is meaningfully a method in most cases, even if implemented as such.
Re:Add detailed message to NullPointerException describing w... by laythea on Tuesday March 26, 2019 @01:51PM (#19494303)
Cannot agree with you more. I personally hate chained expressions. Awful for debugging too.
Re:Add detailed message to NullPointerException describing w... by xxs on Tuesday March 26, 2019 @05:22PM (#19496147)
Java debugging tools are beyond excellent for debugging such code (not that it should be written that way)
Re:Add detailed message to NullPointerException describing w... by laythea on Wednesday March 27, 2019 @02:22PM (#19504206)
I still have to select the sub-expression whose value I wish to inspect. This involves precisely aiming the cursor at text, which is a lot of mental burden (x millions).

A task I thank the developer who creates a variable to hold such a reference, for it creates a much better experience.

Re:Add detailed message to NullPointerException describing w... by wtetzner on Tuesday March 26, 2019 @04:38PM (#19495803)
It's only awful for debugging because the tools are awful.
Re:Add detailed message to NullPointerException describing w... by laythea on Wednesday March 27, 2019 @02:23PM (#19504216)
The tools for Java are greate (try C++ if you disagree).

It's the code that is the problem here.

Re:Add detailed message to NullPointerException describing w... by wtetzner on Wednesday March 27, 2019 @03:24PM (#19504934)
The tools for Java are much better than those for C++. However, claiming the code is the problem is silly. I'm not going to introduce a bunch of local variables just to appease a debugger.

If splitting on separate lines makes code more readable, then sure, do that. But often it just makes the code longer and harder to follow.