Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.*

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top