[英]Meaning of Class count metrics
We are working on a bigger project with Ruby on Rails. 我们正在与Ruby on Rails一起进行更大的项目。 As you might know, Rails works with MVC pattern and typically enforces the following class types for Domain objects: 如您所知,Rails使用MVC模式,通常为Domain对象强制执行以下类类型:
We experienced - like many other teams - that this is not feasible for bigger, long-running projects. 与许多其他团队一样,我们经验到,这对于大型,长期运行的项目是不可行的。
So in our current project, we added some layers, so we typically have 因此,在当前项目中,我们添加了一些层,因此通常
It is much more testable, maintainable and understandable. 它更具可测试性,可维护性和可理解性。 However, our boss disagrees with "These are too many classes". 但是,我们的老板不同意“这些课程太多”。
As he is typically a proficient architect (doing consulting), I don't want to simply reject this response. 由于他通常是一位熟练的架构师(从事咨询工作),所以我不想简单地拒绝这种回答。 However, his time as active Java developer are gone and he often explains such sentences with his improved "gut feeling". 但是,他不再是活跃的Java开发人员,他常常以改善的“直觉”来解释这样的句子。
Of course, there are metrics that count classes - but is there a general approach to classify something like 'Classes per Domain object' or 'Class per Business case', which can be taken for an argument? 当然,有一些度量值可以统计类-但是是否有一种通用方法可以对诸如“每个域对象的类”或“每个业务案例的类”之类的东西进行分类呢?
I have never heard of a rule or best practice which limits a number of classes per project, domain or whatever. 我从未听说过一个规则或最佳实践,该规则或最佳实践限制了每个项目,领域或任何其他项目的类数。 One should create as many classes as he REALLY needs. 一个人应该创建他真正需要的尽可能多的类。 The key word here is "REALLY" because quite often developers over complicate things and create unnecessary classes, layers or even tiers. 这里的关键词是“ REALLY”,因为开发人员经常使事情复杂化并创建不必要的类,层甚至层。 Without the details about your project I suggest you do the following: 如果没有有关您的项目的详细信息,我建议您执行以下操作:
Hope it helps! 希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.