views:

541

answers:

4

What are some good package naming conventions for domain specific object models. For example, say you have a Person.java POJO, would you put it in a mydomain.model or mydomain.entity or mydomain.om (object model) package. The idea is to separate the MVC model objects from the domain object model. Our MVC based application has a model package that contains behavior but using that package to contain our domain object model seems inappropriate and potentially confusing.

+1  A: 

The package name you choose is irrelevant. model vs. domain vs. vo vs. foobar is all fine just as long as your team is all on the same page. I agree that this package should only contain POJO domain objects with no significant business logic.

John Case
A: 

Not only that, be careful in the naming convention of your namespaces. I've seen cases where namespace names where duplicated in different assemblies. Talk about confusion.

Thomas Wagner
+2  A: 

I use "com.mycompany.domain" personally, but that might not be the best answer.

bpapa
A: 

You might want to organize your packages vertically instead of horizontally to seperate functionality.

Eg.

com.foobar.accounting.model.*
com.foobar.accounting.view.*

com.foobar.invoicing.model.*
com.foobar.invoicing.view.*

may be better than

com.foobar.model.accounting.*
com.foobar.model.invoicing.*

com.foobar.view.accounting.*
com.foobar.view.invoicing.*
Martin