• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Package Naming Norms

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am wanting some advice on package naming when writing Servlets and Beans. Should I package my servlets as
com.embeddedthought.ProjectName.Servlets
and dump all my servlets in there. Or should I use that naming scheme and then extend that on with packages defining functionallity of servlets like
com.embeddedthought.ProjectName.Servlets.Operations
And as far as Beans should it be followed the same way as
com.embeddedthought.ProjectName.Beans.....
And so on?
Just looking for some advice. I know there is no "rule" but I do know there is an industry standard and that is what I am looking for.
Thanks.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how about something like:

com.company_name.utilities
com.company_name.tier.component
com.company_name.application_name.tier.component

Some example classes:
com.embeddedthought.data.IProvider;
com.embeddedthought.data.MySQLProvider;

if in the tracker project you needed something special:
com.embeddedthought.tracker.data.OtherProvider extends com.embeddedthought.data.IProvider;
This is an approach I'm using and so far no troubles. (That's me tempting fate)
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So there is no need to seperate Beans from Servlets in packages?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do beans clearly belong to any given tier or are they cross-tier service-type things?

I'm asking, I'm not sure how I'd view them.

do they belong in the 'web' tier? the 'middle' tier, or the 'data' tier? They're used in all 3, to larger and smaller extents. Or maybe they *shouldn't* be, and restrict them to the web tier, and use business object (beans) in the middle tier and data transfer object (beans) in the data tier.

I think a lot of the answers are not "clearly right" and it all depends on how crazy you want your architecture (as expressed through package naming) to get.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that helps. I don't know why I am worried about it. I don't work on projects in groups and all my java projects are personal. so it's really only a problem for me if I lose organization.
I just didn't know if anyone else seperated things like I stated.
What about something like
com.embeddedthought.JBB.data.beans
com.embeddedthought.JBB.data.servlets
??
Would that just be totally unecessary?
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen this .com quite a few times. is it actually a "standard", what exactly does it mean? most of the things I download begin with .com..
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andres Gonzalez:
I've seen this .com quite a few times. is it actually a "standard", what exactly does it mean? most of the things I download begin with .com..


The reason for the com.embeddedthought or whatever is because the standard says take your Domain Name and reverse it so instead of embeddedthought.com you do com.embeddedthought.
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andres Gonzalez:
I've seen this .com quite a few times. is it actually a "standard", what exactly does it mean? most of the things I download begin with .com..


Section 7.7 of JLS gives the pakcage naming convention.


The first component of a unique package name is always written in all-lowercase ASCII letters and should be one of the top level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.


You form a unique package name by first having (or belonging to an organization that has) an Internet domain name, such as sun.com. You then reverse this name, component by component, to obtain, in this example, com.sun, and use this as a prefix for your package names, using a convention developed within your organization to further administer package names.


some examples given:


com.sun.sunsoft.DOE
com.sun.java.jag.scrabble
com.apple.quicktime.v2
edu.cmu.cs.bovik.cheese
gov.whitehouse.socks.mousefinder

 
Trust God, but always tether your camel... to this tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic