• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Main class naming convention

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,

My problem is I'm not sure what to name the main method. I'm wondering if there is any kind of naming convention regarding main classes. The main methods main function is to just call all the other class relavent to the function of the application. So I'm kind of stuck wondering what to name the thing.

Anybody have any suggestions.

Thanks in advance..
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use any name ....which suits your application
[ October 20, 2008: Message edited by: jittu goud ]
 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, and thank you for your reply. I understand that you can use any name, however is there any kind of standard that is applied here? If there isn't then fine, but I'd like to stay with convention if possible.


Again Thanks for your reply!

BW..
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The convention is to give the class a name which describes its purpose, or its function. What it does, or what it is. If your class is solely there to create some objects of other classes and call a method which runs until it's stopped -- this is common in GUI-based programs -- then I don't think it would be unreasonable to call the class "Main".
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Jittu said, you can practically use anything that takes your fancy.
Personally, I follow a few basic rules for my own convenience.

1) The main class should reflect the project name. e.g. I have a main class called "DiskMonitor".
2) Prefix all class names with a project code abbreviation. In this case "DM"
3) The names should be self explanatory. If I got a class called DMTableModel, it is pretty obvious that this is a custom table model.
3) Prefix all interface names with an I. e.g. IDMConstants

So much for the class naming conventions. However, on the other hand, there are coding conventions, which are quite elaborate, and should be really followed by all coders.
Here is a nice article which might interest you.
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maneesh Godbole:
2) Prefix all class names with a project code abbreviation. In this case "DM"


That's where I disagree. For your DMTableModel it makes sense because TableModel is the name of the interface you are implementing, but if such a thing is not necessary then I'd just let the package name make the distinction.

Of course that's all just a matter of opinion.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Prime:

That's where I disagree.



Hehehe.
I was waiting for this from someone.
But like you said, its a matter of opinion.
[ October 21, 2008: Message edited by: Maneesh Godbole ]
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maneesh Godbole:
But like you said, its a matter of opinion.



But I think Rob's opinion is correct
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:

But I think Rob's opinion is correct



That was to be expected as both of you are ganging up on me
 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for your reply. I've seen where programmers also stick test on the end of the main class. Is this common as well?

Again thank to all who replied!

BW
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by B West:
Thank you all for your reply. I've seen where programmers also stick test on the end of the main class. Is this common as well?



A class named XXXTest is not supposed to be a "real" main class for an application; it's supposed to be a test or example program.

As was pointed out earlier "Main" is a perfectly good and common name for the entry-point class for an application; the package name lets you distinguish between the many classes named "Main".
 
B West
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for all your replies. I will use the name of main.

Thanks everybody!
bw
 
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic