aspose file tools*
The moose likes Beginning Java and the fly likes Package syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package syntax" Watch "Package syntax" New topic
Author

Package syntax

Frank Metzger
Greenhorn

Joined: Aug 04, 2011
Posts: 6
Hello,

I have seen packages declared like this: package pkg1, pkg2, pkg3; but have also seen them declared like this: package BookPack1, BookPack2, BookPack3;
Which method is commonly used? Is there a reason, why the later would be used?

vineet dhar
Greenhorn

Joined: Aug 17, 2011
Posts: 23
Dan Storjohann wrote:Hello,

I have seen packages declared like this: package pkg1, pkg2, pkg3; but have also seen them declared like this: package BookPack1, BookPack2, BookPack3;
Which method is commonly used? Is there a reason, why the later would be used?



It is just for your understanding and code maintainability....suppose you have written a code...you know what pkg 1, 2, or 4 does...but when you give this code to someone else for reading, the way of writing for the latter part would be easy to comprehend....So always go for the conventional style of writing and use meaningful variable names...

Vineet
Ronald Castillo
Ranch Hand

Joined: Apr 16, 2011
Posts: 47

I think he's referring to Package naming conventions.

You can pretty much name your packages any way you want (with a few exceptions).
But, as for variable names, a convention is encouraged.

http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38405
    
  23
I would suggest that package names like pkg1 are incorrect because they give no idea what each package contains.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Package syntax