What is your suggestion on where to put cross-cutting concerns in a package-by-feature structured app? This aspect seem to be missing from most of the pro package-by-feature articles I have read.
Consider for example a Java REST api:
com.myapp.authentication AuthenticationResource.java Token.java TokenDao.java ... com.myapp.article ArticleResource.java Article.java ArticleDao.java ... com.myapp.util Security.java (hash, random string, etc...) ...
Now, where would you put the global User object and DAO (used by most features after authentication), and the DB connection used by the DAOs?
And how would you handle cross-dao transactions?
I was thinking maybe have a
endTransaction method on each DAO, and rely on nested transacions. Thoughts?
Another option could be to have a global
DaoManager from which the service layer would request writeable/readable DAOs from, and then commit the result when done. In which case, where to put such a class? Thoughts?
I feel like this is such a common starting point for most apps I am making, which also gets me stuck so quickly.