During a JavaOne IDE-comparison session, in a valiant effort to prove my impartiality, I revealed some of my pet peeves about NetBeans IDE. One of these was this odd scenario:

Above, I have called up a hint to convert an if-else statement to a strings-in-switch statement. However, annoyingly, there's also a tooltip, a meaningless tooltip, taking up space and blocking part of my code. Here's another example:

To me, this looks messy and, worst of all, blocks me from seeing part of my code. Ideally, the tooltip would be removed when the hint is shown. Another point of view might be to make the tooltips more meaningful. But how more meaningful can it be? The problem statement is clear, i.e., we're in a situation where the characters on the opposite sides of the equals statement can be switched. End of story. Let's not waste anyone's time in being verbose about it, in my opinion.

Andrzej "Featureous" Olszak told me at JavaOne that he, for one, agrees with me. So I thought it would make sense to create an issue about this and here it is:


After a bit of discussion in the issue, the problem is now solved, thanks to Jan Lahoda. Using the latest daily build, this is now the default thing I see when prompting the hint to be displayed:

Much better! Of course, if you hover your mouse over the tip/hint combination in the sidebar, you'll still see the tooltip:

However, once the hint has been prompted to be displayed, you'll not see the tooltip anymore:

If you'd like the old behavior back,  pass in -J-Dorg.netbeans.modules.editor.hints.HintsUI.always.show.error=true. This way, everyone's happy. Me, especially! So, this new behavior will be part of NetBeans IDE 7.1.


> But how more meaningful can it be? The problem statement is
> clear, i.e., we're in a situation where the characters on the
> opposite sides of the equals statement can be switched.

On a related note, it might be helpful if the hint could tell you *why* the change is beneficial.

In this particular case, it's pretty obvious to an experienced Java/C/C++ programmer that flipping the strings will avoid a NullPointerException, but it may not be obvious to a beginner.

I've been doing Java since the 1990s, but am sometimes puzzled (usually at the end of a long day) by warnings related to really esoteric cases of generics.

It took a long time for me to realize that the description of the hints are there (you first click the hint, then click the popup message to configure the hints), but it might be helpful to make that description quicker/easier to see. I think I will file an issue to request this enhancement now :-)

Posted by Tom Wheeler on October 20, 2011 at 08:09 AM PDT #

And sometimes it can be usefull unflipped, to check for null implicitely. But I prefare explicit checks, because they allow custom message, so my coworkers or me can easier find source of error. But inside tight loop it can be still usefull.
But if that string is allowed to be null, fliping it is the way to go.

Posted by Martin Juranek on October 20, 2011 at 07:11 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2016