Best designs for breaking down business logic and data layer when they seem to overlap? [closed]

让人想犯罪 __ 提交于 2019-12-03 08:48:24

What kind of strategies do you use when deciding where to break down "business logic" versus "data access logic" when they seem to overlap?

Maybe you can have three layers instead of two: "one extra level of indirection".

At the top layer, you might have business logic which doesn't know about data-access: this business layer uses classes like User, Account, etc., and maybe some factory methods like User.getAccounts and Account.getOwners.

The bottom layer might be a data-access layer, which is your wrapper around or facade to whatever your data layer is.

Between these two layers, a layer which knows what your business objects are (e.g. User and Account) but not what your business logic is. The middle layer knows your data access layer. The job of your middle layer is to use your data access layer's API to I/O your business objects.

"I'm unsure where to draw the line between the business/service layer class and the DAO."

Aren't we all?

I suggest using an ORM (iBatis, Hibernate, Toplink, etc.). Don't implement your own DAO's.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!