This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
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)
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.
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?
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.