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 124219 - Better New Name default for Copy Class
Summary: Better New Name default for Copy Class
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Jan Becicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-18 19:40 UTC by matthies
Modified: 2011-01-13 16:25 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matthies 2007-12-18 19:40:11 UTC
In the "Copy Class" dialog, the default new name is "<old name>1". This is not only useless (wanting to name the copy 
like that should be quite rare), it also creates significant extra work in the very typical case that only some prefix 
of the old name is to be changed, because then the name needs to be edited at both ends. Like when you have 
a "FooCachingStrategy" and want to create a similar "BarCachingStrategy", for example. 99% of the time when using "Copy 
Class", I find myself having to make an extra trip to the end of the name with the cursor to delete that bloody "1". 
It's quite annoying. I'd like to suggest to simply use the old name as the default (just as for "Rename Class"). This 
should minimize the necessary editing in pretty much all cases.
Comment 1 Jan Becicka 2011-01-13 15:22:40 UTC
The very same name cannot be used, if you want to make copy to the same package. Anyway just use Ctrl-C Ctrl-V to different package and the name will be preserved.
Comment 2 matthies 2011-01-13 16:25:53 UTC
@Jan: I think you may have misunderstood the purpose of the requested change.
Of course it is not possible to create a class with the same name within the same package. Nevertheless, it is useful to have the existing name as the initial value of the input field of the "Copy Class" dialog, as a starting point for editing the name. I'm talking about editing the name *before* commiting the dialog, that is before the copy of the class is actually created. Let me explain why having the existing name *without* an appended number is better:

Most often, when copying a class, it is named something like "FooSomething" and you want to name the copy "BarSomething". Or it is named "Something" and you want to name the copy "SpecializedSomething". Or it is named "WhateverFooHandler" and you want to name the copy "WhateverBarHandler". In other words, the new name is usually the old name with some prefix/infix/suffix part added, replaced or removed.

In all of these cases, when editing the new class name, you currently have to remove the "1" (or other number) that was added to the name in the input field of the Copy Class dialog. This is unnecessary extra work and therefore a nuisance. It is more straightforward to change "FooSomething" to "BarSomething" than having to change "FooSomething1" to "BarSomething".

Therefore dropping the number at the end would make for faster copying of a class. Yes, the existing name is not valid for commiting the dialog, and a warning would probably be shown that a class with that name already exists. But the user wants to edit the name anyway; it's very unlikely that she actually wants to name the copy "<old name><unused number>". In the vast majority of cases, the appended number is an unwanted artifact that the user has to remove again. Hence it would be more user-friendly to not add it in the first place.