Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package syntax

 
Frank Metzger
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest that package names like pkg1 are incorrect because they give no idea what each package contains.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic