-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove/rewrite paragraph on McCabe complexity as fraud #21
Comments
The original program ( Splitting the Splitting a function up only makes it easier to test that function if the impact of the functions it calls are ignored. For instance, there will be paths through the sequence of function calls McCabe's original paper uses the same verbal slight of hand that most subsequent researchers have used. He starts off talking about program complexity (all well and good), and then switches to discussing a tool that calculates his metric for individual subroutines. People say that McCabe reduces program testing effort, which it does because it reduces the effort for by causing some functions to be split up. What rarely gets pointed out is that fewer paths through the program are tested. It is accounting fraud. |
This statement is true but irrelevant. Unit tests don't test whole programs. |
What do unit tests have to do with this discussion? McCabe's metric numbers might be considered during unit testing, but that does not validate the metric in any way. It may be the case that the estimated cost of testing is too high and some way of reducing it is required. The McCabe metric might be used as a justification for splitting functions and just testing the new split-up program, with the tester accepting that less thorough testing has been done, but it is within budget. In this case, the role of McCabe's metric is to blind management with techno-babble, so they think everything is ok, and overlook that less testing has been done (which is to be expected on an inadequate budget). |
Remove/rewrite this paragraph because it makes false claims:
The example proves the value of the McCabe metric, instead of the claimed "manipulation". McCabe complexity measure estimates complexity by estimating the difficulty of testing (by estimating effort for branch coverage). The original function had 16 paths, requiring 16 tests for branch coverage. The new set of 4 functions can each be fully branch unit tested with 4x2=8 tests. You would typically want to test the combination (e.g., with integration tests), but that combination would typically not need as many tests (because you have confidence in the units). Reduciing the number of tests that need to be developed across an entire project can have substantial economic value. What's more, what each function does is almost certainly clearer (though obviously it'd be better to measure that).
The McCabe complexity measure is showing, correctly, that splitting up functions tends to make each function easier to test. It's plausible that easier-to-test is also easier-to-understand, though that's a different question.
Obviously you want the McCabe complexity measurement to measure something different than what it measures. That's fine, but complaining that it measures something different than what you want it to measure is irrelevant. It's not accounting fraud; saying it's fraud is demonstrably false.
The text was updated successfully, but these errors were encountered: