• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Package syntax

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 47
MySQL Database PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest that package names like pkg1 are incorrect because they give no idea what each package contains.
 
reply
    Bookmark Topic Watch Topic
  • New Topic