In which NCR PD solves a crime. A crime of passion. A crime... OF BAD CODE.
It's pitch-black inside, so no-one would have seen the door flex and splinter into dust, even if there had been someone alive inside as witness. Grogers stands in the doorway, letting the dust settle in the lines of light streaming through the gaps in the boarded windows. KG pushes past, and rushes to the body to check for a pulse. "He's dead... That makes 5 this week".
KG stands up slowly and scrapes his shoe on the detritus that lines the floor but continues to watch Grogers peeling a wooden board from the window before looking out into the neon soaked night-time. KG feels he should say something. Something reassuring. Something profound. "Rough neighbourhood..." He trails off at the end.
Grogers doesn't reply, emitting only a noise somewhere between a sigh and a grunt as he continues to survey the night from his position at the broken window.
Code quality is a subject dear to all of us at NCR Edinburgh - all you need to do to start a fight at NCR EDI HQ is suggest that Allman was right all along and that K&R is for losers. Of course, that's a purely subjective argument. How can we be more objective about it?
There are many existing ways of measuring the quality of a piece of code - Sonar is a staple around these parts - but the GitShake team have taken inspiration from a TEDx talk by Adam Tornhill about treating your code as a crime scene and also work by Michael Feathers around gathering empirical evidence to support refactoring activities. They envisage a system that can trawl our source code control repositories and draw inferences about the code therein. Which of this code is good? Which of this code needs attention? Are any classes consistent repeat offenders when it comes to harbouring bugs?
GitShake is born.
"We've inherited a few legacy code bases recently and it's a good way to analyse what we've inherited to see where refactoring work should be started", Gordon explains. The idea here is that we can pull data from our Git repositories and look for churn, thus indicating some sort of hot-spot that may be worthy of further examination.
The team have only been coding for a couple of hours as of this conversation, so it's early days in terms of progress: "problems so far are just trying to get the correct data out of our source code control systems."
Under the strain of such an intense Media Team grilling, Gordon starts to look increasingly uncomfortable. In an uncharacteristic act of mercy, we fire him one last question before letting him get on. Anything else you want to say? "No, thank you. That's more than enough".
Grogers stands, arms folded, staring at the workboard. Twine crosses itself, joining an increasing number of seemingly disparate photographs. There's a pattern. There must be.
"I got two" - KG offers his partner a coffee and joins him in the staring. Grogers nods and gets as close to a smile as he has done for a long time. "Harvey says hey and to give you this. Oh - he also says to cut down on your caffeine. He says it's not good for you". The near-smile again. Grogers feels around in the manilla envelope and pulls out a map. There's a beat, and then Grogers throws his coffee on the ground and makes for the door.
KG gives chase, grabbing his jacket from the back of his seat and putting it on in one well-practiced motion, all the while maintaining an unspilled coffee - "Where we headed?". Grogers doesn't look back, replying deliberately quietly so KG can't hear: "a rough neighbourhood". The smile.
We're back with Gordon on day 2, getting the latest: "Kevin broke the code by making it windows specific; I wrote the most complex regex in a year and we've lost count of how many cups of tea we've had." Oh, right. Anything else? "We've got something running: history can be parsed, file changes observed and graphs produced. We also switched from Gitlab API to Gitlog as we couldn't access to what we needed".
Anything left after all that? "Loads. We'd like to add Perforce as a supported SCCS and create plugins for Maven and Sonar"
A good, solid, no-nonsense group, these guys have decided on a plain ol' Java app producing HTML with a little bit of d3.js for the graphing and it's clearly paying off.
Next up? Slightly ironically - identifying and fixing bugs. So... what would happen if we were to run GitShake on itself? WE'D SEE NOTHING BUT CODE OF THE HIGHEST QUALITY, THAT'S WHAT, NOTHING TO SEE HERE MOVE ALONG.
"Send the boys around the back. We've got the front". A scuffling of boots leaves KG and Grogers alone in front of a run-down building, more patch than brick. The walls are scarred and the front door is kicked in. "Looks like we're not the first to try this". There was certainly evidence of a few attempts, Grogers had to admit, but this time they knew where to look. They had the numbers. They had evidence.
"You really think this is the source of our problems?". Grogers grins. "I don't think... I know". He slowly clenches and unclenches his fists, and reaches for his holster. "We'll tear this place apart if we have to". KG nods and cracks his knuckles.
We get a speedy demo from the GitShake chaps once they get started (after some excellent audience debugging of an issue with Chrome when you plug in an external display. Ratna even got involved. Bless). Kevin's up:
"Hi. We were working on GitShake, because we think metrics are fun".
Once going, they fly through bar charts, treemaps, Sonar plugins and all sorts, pausing only to point out various modules with high churn that we always suspected were, er, suspect. Anyway, no-one was shocked and we shall mention no names in order to protect the guilty. Blame culture? No' here, pal.
Needless to say, it all looks awesome and with excellent mic technique to boot, these guys are ones to look out for come the main prizegiving. In the meantime, Ratna awards them a protein shake bottle (GEDDIT?!), which ends up on the office swap board mere hours later. Clearly we're less concerned with prize churn than code churn.
The demo is done. Gordon drops the mic. Applause fills the room and when it dies down, only anticipation for the next team remains.
Grogers: Gordon Rogers, KG: Kevin Grant, Harvey: Hervé Saint-Amand
Tags: codefest, codefest summer 2015
September 14th 2015