Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DAO & Business Logic [closed]


I was wondering about the amount of business logic that a DAO should deal with.

Ok, we all know that the purpose of DAOs is to encapsulate data access and hide all the informations about it as well as the implementation. Furthermore, the goal of DAOs is also to separate business logic from data access logic.

I would argue that a DAO must have some business logic in it, e.g. what if a business object could not be deleted or updated due to some requirements of the specific domain? I guess that no one would implement the delete/update method for that DAO, and -for as I see it- this implies some knowledge of business logic.

Now, as you can imagine my question is more conceptual than practical, so it's useless advice to use an ORM as there is no concrete scenario of use.

The question is: how much business logic a DAO should handle, given any restriction on the manipulation of persistent data?

Example:
BusinessObject1 can be updated only once in its lifetime. Supposed that we can easily know if it has already been updated, should the DAO throw an exception if we try to update BusinessObject1 again? Or it should detect nothing and this should be managed in the business layer?

like image 643
kelo Avatar asked Aug 31 '12 10:08

kelo


People also ask

Whats DAO means?

A DAO, or “Decentralized Autonomous Organization,” is a community-led entity with no central authority. It is fully autonomous and transparent: smart contracts lay the foundational rules, execute the agreed upon decisions, and at any point, proposals, voting, and even the very code itself can be publicly audited.

What is a DAO in crypto?

A decentralized autonomous organization (DAO) is a software running on a blockchain that offers users a built-in model for the collective management of its code. DAOs differ from traditional organizations managed by boards, committees and executives.

What is an example of a DAO?

DAO examplesA charity – you could accept donations from anyone in the world and vote on which causes to fund. Collective ownership – you could purchase physical or digital assets and members can vote on how to use them.

What does DAO mean in NFT?

NFT platforms continue to reinvent themselves with the latest innovation and ideas. For instance, NFT platforms are now adopting the decentralized autonomous organization (DAO) model regardless of the purpose they serve.


1 Answers

If you store your data in a database that has referential integrity rules, then your data layer has business rules in it.

This is the problem with all rules of thumb. They work until they don't. The point is not to avoid rules in your data layer, the point is to only put rules in the data layer that belong there. For example, rules which enforce the validity of stored data belong in the data layer. Rules that enforce how data is used don't belong in the data layer.

like image 75
Joel Brown Avatar answered Sep 18 '22 12:09

Joel Brown