aspose file tools*
The moose likes Servlets and the fly likes Package Naming Norms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Package Naming Norms" Watch "Package Naming Norms" New topic
Author

Package Naming Norms

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

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.


GenRocket - A Test Data Generation Platform
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

So there is no need to seperate Beans from Servlets in packages?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

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?
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
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..


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

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.
Rajeshwari Natarajan
Ranch Hand

Joined: Mar 05, 2003
Posts: 67
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


regards<br />Rajeshwari. N
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package Naming Norms
 
Similar Threads
A big JavaRanch welcome
Package structure in Struts
jsp cant call bean in websphere
JSWDK (JavaServer Web Development Kit)
Entity Beans vs Java classes and Servlets