Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In C# how many lines before a class should be consider to be refactored? [closed]

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

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.

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

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?

like image 622
David Basarab Avatar asked May 11 '09 19:05

David Basarab


People also ask

What is '~' in C programming?

In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...

What does != Mean in C?

The not-equal-to operator ( != ) returns true if the operands don't have the same value; otherwise, it returns false .

What is the use of in C?

In C/C++, the # sign marks preprocessor directives. If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more.


1 Answers

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

The single responsibility principle is a computer programming principle that states that every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility

like image 85
Mark Sherretta Avatar answered Oct 12 '22 13:10

Mark Sherretta