naming conventions - Are there best practices for (Java) package organisation? -
a little while ago, saw question answered here regarding fine-grained organisation of java packages. example, my.project.util, my.project.factory, my.project.service etc.
i can't find now, may ask question.
are there best practices regards organisation of packages in java , goes in them?
how organise classes in java project?
for instance, project i'm working on few people has package called beans. started out being project containing simple beans, has ended (through poor experience , lack of time) containing (almost). i've cleaned them little, putting factory classes in factory package (classes static methods create beans) have other classes business logic , others simple processing (not business logic) retrieving message code properties file.
your thoughts , comments appreciated.
package organization or package structuring heated discussion. below simple guidelines package naming , structuring:
- follow java package naming conventions
- structure packages according functional role business role
- break down packages according functionality or modules. e.g.
com.company.product.modulea
- further break down based on layers in software. don't go overboard if have few classes in package, makes sense have in package. e.g.
com.company.product.module.web
orcom.company.product.module.util
etc. - avoid going overboard structuring, imo avoid separate packaging exceptions, factories, etc. unless there's pressing need.
- break down packages according functionality or modules. e.g.
- if project small, keep simple few packages. e.g.
com.company.product.model
,com.company.product.util
, etc. - take @ of popular open source projects out there on apache projects. see how use structuring, various sized projects.
- also consider build , distribution when naming ( allowing distribute api or sdk in different package, see servlet api)
after few experiments , trials should able come structuring comfortable with. don't fixated on 1 convention, open changes.
Comments
Post a Comment