On 07/21/2011 10:27 AM, Matthew Farwell wrote:
Salut,
+1 for the simplicity of this. Keep it simple. Unless you have lots[*]
of classes that are part of the api, just put all of the api in one
package and the rest in another. I don't like the name 'impl', but it
is fairly well understood that impl means the implementation of an
interface, not necessarily part of the external api. So I would use
impl as well.
BTW, I don't like it too - but it's e.g. a standard in OSGi if I'm not
wrong (I think that the maven-felix-plugin automatically excludes *.impl
from the published stuff, right?), as well as widely used in the
NetBeans Platform.
Don't just create packages because you can. Create packages to help
the developer/maintainer understand the api.
As well as this, you avoid arguments over what the packages should be
called, and whether or not a class belongs in a package. Should
BufferedInputStream be in java.io.buffered, or java.io.input or
java.io.stream? With the scheme proposed by Fabrizio, the decision is:
Is the class part of the api? Yes/No. End of discussion. Now you can
move one to arguing about the name of the class, or arguing about
whether or not there should be a space around a +. :-)
BTW, I have to say that I also use a 'subpackage' scheme, which is
orthogonal to the previous one: e.g. "model", "ui", but this is usually
related to the (Maven module I'm compiling).
I also have to add that I'm still unsatisfied with my rules, as when it
comes to "freezing" an API, I still find myself in the need of moving
classes around - a smell that my rules aren't well defined. In any case,
this consideration goes in the direction "keep the packages to a minimum".
--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
[email protected]
--
You received this message because you are subscribed to the Google Groups "The Java
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.