DAO模式会破坏内聚性/SRP吗? [英] Does the DAO pattern spoils cohesion /SRP?
本文介绍了DAO模式会破坏内聚性/SRP吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以我们为例:
class AccountDAO {
create(){..}
read(){..}
update(){..}
delete() {..}
}
有多少职责? 1或4?
How many responsibilities are there? 1 or 4?
推荐答案
不应严格理解SRP.一个对象应该承担的责任很少,而不是一个".
SRP shouldn't be understood in a strict manner. One object should have very few responsibilities, not "one".
在这里AccountDAO仅负责帐户的持久性,因此它只负责一项.
Here AccountDAO is only responsible for Account persistence, so it has only one responsibility.
这篇关于DAO模式会破坏内聚性/SRP吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文