Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what names should I give as project name, package name, class name - (java - eclipse )

Tags:

java

eclipse

I have never understood what is the ideal way to name a project, package, class. I do it in a random way which doesn't look professional at all. I know the class name should start with a capital alphabet. But what I don't really have trouble with is finding the names that are suitable and look professional. lets consider this example. If I am writing a program for fibonacci series i give names like this:

project name = fibonacci_project
package name = org.fib.code1
class name = Code1

Doesn't look neat right? How would you do it ?

like image 893
silverkid Avatar asked Dec 11 '09 07:12

silverkid


2 Answers

There are some tips about naming:

  1. As you said classname have the capitalization of first letter of every word, eg. LongClassName
  2. Sun always preferred long names that explain clearly the meaning of the class (think about DefaultTableModel). Code1 is definetely not right, maybe FibonacciCalc or something that contains Fibonacci would fit better.
  3. Preprend Abstract if it's an abstract class
  4. Append Impl if it's an implementation of a particular interface
  5. Package names should start with org, com, it, etc (usually it was the backward URL of project repository or the nick of the coder)
  6. You should split your packages according to functionality, your example is really simple so there is not a way to do it.

Think about something more complex in which you have:

org.package.gui
org.package.core
org.package.extensions
like image 104
Jack Avatar answered Sep 20 '22 10:09

Jack


For starters, it's Fibonacci.

See Sun's java naming conventions for some details on package / class names.

Aside from that, the general rule of thumb is - all your names should be descriptive:

  • for class - what does it do (or what does it represent)
  • for package - what common functionality (goal) do all classes within that package provide (aim to achieve)
like image 40
ChssPly76 Avatar answered Sep 23 '22 10:09

ChssPly76