This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
you can use any name ....which suits your application [ October 20, 2008: Message edited by: jittu goud ]
Joined: Oct 10, 2008
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.
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".
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
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.