Mixing Data access logic and business logic
I was looking through the sample application code of the Professional Struts Applications books. Overall, this is the best book on Struts that I have - thanks a lot for the excellent work.
I understand that for the sake of simplicity, it was chosen that the Data Access Objects provide the actual "business methods" - e.g. for the code on pg.186, they provide a method "findTopStory", etc. So, the findTopStory method has some code that essentially represents the business rules (e.g. query.setStartAtIndex(1), query.setEndAtIndex(MAXIMUM_TOPSTORIES-1) ).
So, my question is, if you didn't have to simplify the code for the purpose of the book, where would these business rules end up ? Maybe in the Story Manager class ? If that is the case, then there should be some way to pass the selection criteria to the DAOs, which in turn would create a dependency on the OJB data access methods (e.g. if we use the OJB Criteria classes to encapsulate the selection criteria).
|