cumulativehypotheses

mostly professional blather

Distribution of Complexity in jMock

with 4 comments

Suppose we were to take methods one by one, at random and without replacement, from the source code of jMock 2. How would we expect the Cyclomatic Complexity of those methods to be distributed?

Here you will find some automation to discover the raw numbers, and here is a Mathematica Computable Document (get the free reader here) showing the analysis.

Result:

This evidence suggests that the Cyclomatic Complexity per method in this version of jMock is distributed according to a discrete power–law distribution with shape parameter ρ ≈ 1.92

Probability of Complexity of Methods in jMock 2

This chart shows the empirical probability of a given complexity in blue and that from the maximum–likelihood fitted power–law distribution in red. Solid lines show where the fitted distribution underestimates the probability of methods with a certain complexity occurring, dashed lines where it overestimates.

Note that both scales are logarithmic.

Other long-tailed distributions (e.g. log-normal) can be fitted onto this data, but the hypothesis that they represent data is rejected at the 5% level.

Advertisements

Written by keithb

August 17, 2011 at 2:01 pm

4 Responses

Subscribe to comments with RSS.

  1. I can’t browse the source on bitbucket without a login. Is there a public URL for it?

    Nat

    August 17, 2011 at 3:35 pm

    • Um, I’m confused. The “private repository” tickbox is un-ticked on that repo, but it still appears to be private. Could you try again now?

      keithb

      August 17, 2011 at 4:00 pm

  2. Just guessing, the high complexity methods in JMock are mostly calls to ‘new’ right?

    tcrayford

    December 8, 2011 at 5:56 pm

    • Before digging in to what the high complexity methods in JMock actually are like, could you expand on you thoughts? What’s behind your guess? I’m keen to understands what people’s intuition about this sort of thing is.

      keithb

      December 8, 2011 at 9:35 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: