在实体被认为臃肿之前,我们可以合理地在实体中放入多少种方法?
通过所有有关单一责任原则、分解等的阅读,很难了解实体变得臃肿的警报信号应该是什么。
是否有一些好的建议/阅读某处关于我们应该考虑最多多少种方法,或者是否有一些客观的其他标准?
With all those readings about single responsibility principle, decomposition, etc., it's difficult to get an idea of what should be the alarm signal that an entity gets bloated.
Is there some good advice/reading somewhere about how many methods we should consider a maximum, or if there are some objective other criteria?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,SOLID原则应该被视为指导方针,而不是严格的规则。 SOLID 违规通常是设计问题的可靠指标。但有时它们是不可避免的。
有相当多的代码指标。来自 NDepends:
20 是 NDepends 作者认为的合理阈值。以下是来自objecteering的另一个观点:
正如您所看到的,这些指标非常主观。因此,您必须决定什么对您和您的团队有意义。从 DDD 的角度来看,我发现使用 值对象 是减少实体上 SRP 违规的一种非常好的方法。
In my opinion SOLID principles should be treated as guidelines, not as strict rules. SOLID violation is usually a reliable indicator of a design issue. But they are unavoidable sometimes.
There are quite a few code metrics. From NDepends:
20 is what NDepends authors considered to be a reasonable threshold. Here is another opinion from objecteering:
As you can see these metrics are quite subjective. So you have to decide what makes sense for you and your team. From DDD perspective I found that using Value Objects is a very good approach to reduce SRP violations on Entities.