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 189591 - Enhancement: default name of main class
Summary: Enhancement: default name of main class
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords: USABILITY
Depends on:
Blocks:
 
Reported: 2010-08-17 12:28 UTC by boblang99
Modified: 2010-09-01 03:29 UTC (History)
2 users (show)

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 boblang99 2010-08-17 12:28:24 UTC
Product Version = NetBeans IDE 6.9 (Build 201006101454)
Operating System = Mac OS X version 10.6.4 running on x86_64
Java; VM; Vendor = 1.6.0_20
Runtime = Java HotSpot(TM) 64-Bit Server VM 16.3-b01-279

When creating a new Application project, there is an option to create a new class with a main () method.  The default name for this class is Main. java.

I don't like this name and prefer to use the project name as the main class, but this means I have to enter the project name twice- once for the project name, and once more for the main class. This double entry means that I'm at risk of getting the second entry wrong when I retype.  I also need to take care to preserve the package name and dot.  Although this is possible, it's an added cognitive load.

A really useful enhancement would be some preference option which would use the project name as the main class.  This means that if I enter MyNewProject as the project name, the main class is automatically created as MyNewProject.java and I don't have to type "MyNewProject" more than once.

Thanks

Bob
Comment 1 Jesse Glick 2010-08-25 14:36:51 UTC
Might be a better default, especially if it would "autocamelize" your project name, which does not necessarily look anything like a Java class name. The question is what to do with the generated package name. Does the following make sense or is it redundant?

Name:       [test-frobnitz-download]                      (entered)
Folder:     [/tmp]                                        (entered)
Location:   [/tmp/test-frobnitz-download]                 (computed)
Package:    [test.frobnitz.download]                      (suggested)
Main Class: [test.frobnitz.download.TestFrobnitzDownload] (suggested)
Comment 2 boblang99 2010-08-25 21:28:36 UTC
(In reply to comment #1)
> Might be a better default, especially if it would "autocamelize" your project
> name, which does not necessarily look anything like a Java class name. The
> question is what to do with the generated package name. Does the following make
> sense or is it redundant?
> 
> Name:       [test-frobnitz-download]                      (entered)
> Folder:     [/tmp]                                        (entered)
> Location:   [/tmp/test-frobnitz-download]                 (computed)
> Package:    [test.frobnitz.download]                      (suggested)
> Main Class: [test.frobnitz.download.TestFrobnitzDownload] (suggested)

I think the suggested package name (test.frobnitz.download) and suggested Main class name (test.frobnitz.download.TestFrobnitzDownload) both make good sense.  My personal usage is to use a camel name for the project (eg MyJavaProject) and I would not want the to lose the embedded capitals in the main class name (ie. MyJavaProject.java is fine, but Myjavaproject.java is not).  Obviously, there is a convention that package names do not contain caps.

Additionally, for compatibility with previous versions, I would also allow the option for a user to stick with Main.  I don't want this change to be forced upon an unwilling user.
Comment 3 Tomas Zezula 2010-08-26 12:42:02 UTC
>Additionally, for compatibility with previous versions, I would also allow the option for a user to stick with Main.
This will require an additional UI option in the wizard and will complicate the UI. Anyway it's just a default which can be changed by the user in the 2nd step of the wizard.
Comment 4 Tomas Zezula 2010-08-26 14:26:08 UTC
Jesse's proposal seems good, I will do it in this way.
Comment 5 Tomas Zezula 2010-08-30 16:01:39 UTC
The only question is what to do with project names like: for-download-project where the camel case part is a keyword and it cannot be a package name. Should we ignore it (download.project) or escape it somehow like (forpkg.download.project)? I would prefer the escape, eg. by suffix pkg.
Comment 6 Tomas Zezula 2010-08-31 13:11:19 UTC
Fixed jet-main dbb301a14469
Comment 7 Quality Engineering 2010-09-01 03:29:17 UTC
Integrated into 'main-golden', will be available in build *201009010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/dbb301a14469
User: Tomas Zezula <tzezula@netbeans.org>
Log: #189591:Enhancement: default name of main class