Does the DAO pattern spoils cohesion /SRP?

孤者浪人 提交于 2019-12-11 05:38:41

问题


Let's use as example:

class AccountDAO {
    create(){..}
    read(){..}
    update(){..}
    delete() {..}
}

How many responsibilities are there? 1 or 4?


回答1:


SRP shouldn't be understood in a strict manner. One object should have very few responsibilities, not "one".

Here AccountDAO is only responsible for Account persistence, so it has only one responsibility.



来源:https://stackoverflow.com/questions/6483392/does-the-dao-pattern-spoils-cohesion-srp

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