Re: Ambiguous Refactoring Solution
Adam Sroka <[email protected]>
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <[email protected]> |
Let's approach this from a different angle:
We've got a class with 613 LOC. Let's round that down to 600. Then,
let's assume that half of that is for fields, constants, precompiler
declarations, etc. and half is for methods. Then, let's further assume
that half is for whitespace between and within declarations and half
is actual code. That leaves us with 150 lines of method declarations.
Further, we'll take OP at his word that the average method is 2-3
lines. In fact, let's round up to 3. That means 50 methods.
Now, we'll assume that each of those small methods has only one
parameter and one return value and no conditional branching. Thus, the
MCC (McCabe Cyclomatic Complexity) of each method is one.
If we add together the complexities of all the methods we get the
value for a metric known as Weighted Methods per Class (WMC). That
value would be 50. Tools that check WMC will raise a warning for
values over 40 which means that the class is overly complex.
So, according to standard software metrics, given some very
conservative assumptions, the class we are talking about is overly
complex. I'm willing to bet that the complexity is actually quite a
bit higher.
In fact, a class with a WMC as low as 1 is considered valid (Has one
method with no branching.) So, we could make this one class into as
many as 50 and it would be an improvement (Though likely four or five
would be ideal.)
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/refactoring/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/refactoring/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/