Look At All The Code I Wrote!

/via https://abstrusegoose.com/432
Every time I hear stuff along the lines of “Look at all the code I wrote”, I check for code-coverage. And I’ve never, ever been disappointed (in a bad way).
It’s amazing really — as far as I can tell, the propensity to brag about lines of code written is inversely proportional to test coverage .
“I don’t worry about code coverage — that’s what the QA group is for”
 — #CowboyDeveloper
One way to measure the complexity of a piece of code is Cyclomatic Complexity, something Thomas McCabe came up with it back in 1976. At heart it is the number of linearly independent path through code. Or, to put it differently, think of it as all the possible ways in which a given piece of code can actually do whatever it is doing.
As you’d expect, the more paths there are through code,
  1. 1. the harder it is to keep track of things, and as such, the more documentation you should have. Also
  2. 2. the more likely it is that things that can go wrong, and consequently, the more test cases (and coverage!) you need to make sure this doesn’t happen.
Well, research has shown pretty conclusively (•) that Cyclomatic Complexity is directly proportional to lines of code. To quote
This research presents evidence that LOC and CC have a stable practically perfect linear relationship that holds across programmers, languages, code paradigms (procedural versus object-oriented), and software processes…These files represent software projects from three target languages (C, C++, and Java) and a variety of programmer experience levels, software architectures, and de-velopment methodologies. The models developed are found to successfully predict roughly 90% of CC’s variance by LOC alone
So let’s connect the dots, shall we?
  1. 1. #CowboyDeveloper write a s**t-ton of code
  2. 2. The cyclomatic complexity is, as a result, off the charts
  3. 3. Therefore he needs to document his code thoroughly, and
  4. 4. He need all sorts of test-coverage on your code
What do you think the odds are that he actually did document the code”? And how much test-coverage do you think there is? Remember, this is a #CowboyDeveloper that we are talking about 
That, my friends, that is why, whenever I hear “Look at all the code I wrote!”, I flinch.
It’s because it’s almost always a #CowboyDeveloper saying this.
And what he’s actually saying is “Look at all the problems I’ve created!”.
In the immortal words of Edsger Djikstra, “Lines of Code — Do not regard them as ‘lines produced’ but as ‘lines spent’”.

Comments

Popular posts from this blog

Erlang, Binaries, and Garbage Collection (Sigh)

Visualizing Prime Numbers

Its time to call Bullshit on "Technical Debt"