Where to put things
In a layered architecture, how do you know where to put your classes?
I am currently working on a nice little layered architecture at work that is comprised of about six layers. The problem we keep running into is where classes should be put. For example, we have a layer called Object Model that basically contains our domain model classes. To us, this makes sense. We also have a layer for persistence that contains Hibernate and all our DAO classes. The question is though, where do Hibernate mapping files go? They are an element of the persistence layer as they are only really used by Hibernate, but they are very tightly coupled to the objects that they represent which all exist in the object model layer. So an argument could be made that they belong in either layer.
This can be extended to include other examples as well. For testing, we use a class called HibernateTestUtil.java that configures Hibernate to work outside of JBoss. Since this class is only being used for testing, should it go in the test source directory? On the other hand, it has to be accessible to the main source files in order for them to work with Hibernate.
Do other people have this problem when trying to create layered architectures?