If your application is divided into components that are independent of each other, you end up with a business component, a database component (possibly implemented as a DAO), and a user interface component. The business logic component is responsible for enforcing the basic business rules for the application; a database component for accessing data and enforcing data manipulation rules; and finally, a user interface component for managing user interaction.
With this design, there is no argument about whether the database component should contain logic: of course, it should be. He needs rules to control the storage, retrieval and interpretation of data. However, the type of logic it contains is different from business logic or user interface logic. And, as already indicated, the database component should not be a software component; it may consist of stored procedures, functions, and triggers in your database.
In essence, feel free to introduce logic into the DAO, but make sure that this logic only applies to operations that are related to data access. Likewise, it is good to have logic in the user interface component to control user interaction.
user1342582
source share