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.
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 +. :-) [*] For your definition of lots. There are no hard and fast rules, but for instance java.io has about 60 classes in it, and it doesn't feel 'big' to me. Matthew. 2011/7/21 Fabrizio Giudici <[email protected]> > On 07/20/2011 08:46 PM, Adam Brons wrote: > >> Hey Gang, >> >> I was hoping that the masses could help solve a naming problem that >> myself a few other leads are having with deciding on a package naming >> convention for models and services that are going to be externally >> published. >> >> We've thrown around ideas like >> "com.example.appname.**servicename.api.model", >> "com.example.appname.**servicename.published.model", >> "com.example.appname.**servicename.external.model", and >> "com.example.appname.**servicename.framework.model". We're not stuck on >> any of these names, but aren't able to think of anything better or >> decide on one we've listed. >> >> This is a complete experience / opinion question see feel free to >> weigh in, all comments are welcome. >> > I personally follow this personal scheme: > > com.example.appname.**servicename.* for anything that is to be > exported and directly used by client code (API) > com.example.appname.**servicename.impl.* for anything that is only a > local, private implementation > com.example.appname.**servicename.spi.* for anything that is to be > exported, but not directly used by client code, rather by extensions of the > module to provide alternate implementations > > -- > 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.
