This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 131240 - equals/hashCode inclusion UI is non-intuitive
Summary: equals/hashCode inclusion UI is non-intuitive
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2008-03-26 22:14 UTC by fommil
Modified: 2013-09-02 14:21 UTC (History)
1 user (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description fommil 2008-03-26 22:14:17 UTC
NetBeans 6.1 beta.

I find the new equals/hashCode insert UI to be very non-intuitive. It requires the user to tick on which fields to include in the equals... and then again for the 
hashCode. I would intuitively expect to be able to select the fields once for equals and have them included in the hashCode automatically. I have been stung 
by forgetting to recheck the fields for inclusion in the hashCode.

The case where the user wants the fields to be a part of both equals and hashCode is *much* more regular than the corner-case where it is not.

I strongly suggest a rethink into the UI of this dialog... with my recommendation being to have a single selection box for inclusion of fields in both equals and 
hashCode. If the user wishes to customise it any further, they can edit the generated source code!
Comment 1 Jan Becicka 2008-05-15 13:19:43 UTC
Max volunteered :)
Comment 2 tomwheeler 2008-11-05 20:26:17 UTC
Also, the generate equals/hashcode dialog doesn't have checkboxes for superclass fields.
Comment 3 tomwheeler 2008-11-05 20:28:35 UTC
I guess ideally, it should look a bit more like the "Generate Getters and Setters" dialog, only split on two sides: one
for equals and one for hashCode.  Checking or unchecking one box on either side should have the same effect on the other
Comment 4 fommil 2008-11-05 20:33:23 UTC
"Checking or unchecking one box on either side should have the same effect on the other side."

Then why have 2 sides? I really don't think there is a need to have 2 sides... the coder should be smart enough to remove the lines of code that are irrelevant.

Nowadays, I use Google Collections' Objects class and ignore the Netbeans auto-generate code because it is so ugly and the process is so painful that it is 
actually quicker to write the code by hand! (Or have a macro)
Comment 5 tomwheeler 2008-11-05 20:38:08 UTC
I guess having two sides would be more flexible, but not required.  To your point, developers generally use exactly the
same fields for equals and hashCode implementation so having a one-sided dialog would be simpler for typical case.  And
as you state, the developer could modify the generated code by hand afterwards to achieve some different result.  
Comment 6 tomwheeler 2008-11-24 19:40:42 UTC
I was generating the equals/hashcode methods for a class with many significant fields and it's a bit tedious to check
every box.  It would be great if the UI supported a "check all" / "uncheck all" feature like the one for generating
getters and setters does.