How many lines of code can a method with a good design have before you need to make the design better?
Code lines are an incomplete metric used for refactoring. Cyclomatic Complexity should be used in combination with LOC as a worthy indicator for when you need to refactor.
Decent landmark
LOC > 80 || CC > 10 == "Time to refactor"
Most likely, you will encounter Cyclomatic Complexity> 10 long before you reach 80 lines of code.
Of course, there are many other indicators:
, , , , , " 40 !"
. . , 5 10- , . 50- . , , , 6 .
, . , - .
:
, . , , " ", , - .
, , 25 , , , .
, 25 , , . , .
, , .
1000 , , . , , , , , . - 1000 , . .
- , - . , , , , .., . , , . , , , .
if (color.r == color.g && color.r == color.b) if (color.r > 128) newColor = color.White; else newColor = color.Black;
if(isGray(color)) newColor = thresholdGray(color)
, .
, LOC - , , ( ). - , - , . ; - , , 20 30 . , , LOC. .
LOC, - , , , .
. . LOC, . 30 , . LOC; , (, ) . , - .
, "", , . , LOC .
The next rule of thumb that we can follow is to limit the length of the method that we can see on one screen.
Source: https://habr.com/ru/post/1774402/More articles:Google Analytics and the static subdomain - cookiesExcel and awk disagree with CSV results - linuxgoogle-toolbox-for-mac iphone unit test: 1073 Abort trap mkdir "$ CFFIXED_USER_HOME" Command / bin / sh with exit code 134 - iphoneClass vs ID in css (confusion) - htmlUbuntu 9.04: Pecl extension downloads but doesn't install - phpWPF UserControl on parent modified event - wpfResume installer after restart - .netFinding a blog engine for use with the Google App Engine - javaHelp with a Linq expression to return a list of strings based on the number of fields - c #OpenOffice Transfer Algorithm - What do the parameters mean? - cAll Articles