在C#中一个类前应该考虑多少行重构? [英] In C# how many lines before a class should be consider to be refactored?

查看:132
本文介绍了在C#中一个类前应该考虑多少行重构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个好的经验法则是,我智能地重构50行以上的任何方法。

A good rule of thumb by is that I intelligently refactor any method over 50 lines.

计数不包括注释和空格,而是实际代码。我也明智地说的原因是有很多次,超过50行的课程是可以接受的,不能或不应该改变。

The count does not include comments and white space but actual code. The reason I also say intelligently is there are plenty of times where a class over 50 lines is acceptable and cannot or should not be changed.

我没有规则thumb for classes。一般来说,我不检查类,看看他们是否应该重构。

I do not have a rule of thumb for classes. Generally I don't check classes to see if they should be refactored.

在我目前的项目中,我刚刚完成了一个将近4000行长的类。然而没有超过50的方法,并且大多数行和方法是私有的,并且不对类外的任何数据起作用。

On my currently project I have just about complete a class that is almost 4000 lines long. However no methods over 50, and most of the lines and methods are private and not acting on any data outside of the class.

重构类的经验法则是什么?

What is the rule of thumb for refactoring classes?

推荐答案

当类违反 SRP ,现在是重构的时机。

When the class violates the SRP, it's time to refactor.

这篇关于在C#中一个类前应该考虑多少行重构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆