Who Is Responsible For "Good Code"?
A few weeks back, I wrote a post about getting ready to address a coworker's bad code. This sparked some conversation across various media, including the following interesting question:
...seems that there is a breakdown in managing the development process. Why is Bob allowed [to keep] writing bad code?
This feedback is interesting enough to merit a blog post in and of itself. I recognize a question that cuts to the heart of a software development conundrum when I see it. The structure of most organizations that employ software developers is this: the developers responsible for code report up through a structure of people that don't. To put it another way, the people responsible for personnel management usually don't understand how to evaluate the work of those reporting to them -- at least not directly.
Even if people with titles such as "Director of Software Engineering" or "Development Manager" had been developers at some point, asking them to perform code reviews isn't a solid approach. It wouldn't scale well. Imagine asking someone to do detailed code reviews with seven or eight people while also doing all of the other things a manager is required to do, such as budgeting, dealing with other departments, worrying about software licensing, etc. And that's even assuming they're technical. Most managers have to squint pretty hard into their rearview mirrors to see the last time they wrote a lot of code, if there ever was a time.
Typically, managers will rely at least in part on results and observable behaviors. Does the developer keep long hours? Does the developer take one for the team? Did the developer heroically work 90 hours last week to get the code out on time? Did the developer fix a lot of bugs, or better yet, write code in which not a lot of bugs were reported?
All of that sounds reasonable until you think of technical debt. “Technical debt” is a term that describes a trade: when you take shortcuts in the code in order to ship today, it’s at the cost of having a mess when you try to ship down the line. For a great visual of this, imagine a child tasked with cleaning his room who simply stuffs all of the clutter and food debris under the bed. In this light, the very developers that managers view as effective may be writing awful code and making a mess. Tired developers, working 90 hour weeks, are almost certainly thrashing in a tech debt cycle -- making heroic efforts to overcome problems that they created in the first place by making a mess.
It's hard for a manager to make any form of direct evaluation, even when it seems as though there are easy ones to be made.
Metrics to the Rescue?
Okay, so they can't make direct evaluations. What about indirect ones? Well, those are tricky as well. One of the most common traps for software management, particularly if it's not terribly mature, is the allure of metrics. Perhaps you've heard calls for a team build that reports unit test coverage, method size, or cyclomatic complexity? If a manager could get access to those statistics, the reasoning goes he/she could know who on the team was writing good code and who wasn't.
Be careful what you measure. It's possible to achieve a high degree of unit test coverage by writing test methods that don't assert anything. You can keep method size under control by having classes with thousands of tiny methods. Perhaps the most iconic example of unintended consequences for measuring developer productivity is the mountains of terrible code that resulted from managers, at one time, trying to measure developer productivity in lines of committed code. Metrics are tempting for managers, but there be dragons. Relying on metrics to measure developer effectiveness has not historically been a path to success.
Measurement via Human?
If the managers who make personnel decisions can't rely on themselves to evaluate developers and they can't rely on machines to do it, what choice is left? Clearly, they're going to have to turn to other humans to do this. Common patterns that you see are the appointment of a trusted advisor in the form of someone with a title like "Architect" or "Tech Lead." Or perhaps they take a more egalitarian approach, like having the developers perform peer reviews or pair program. In this fashion, the manager delegates evaluation to people in a position to do it, and she uses the information they furnish to make decisions.
This is a familiar pattern, and I imagine that you might be nodding right now. But, going back to the original question, what if Bob--the one checking in the bad code--is a senior team member or even the architect? Think it's not possible? It happens all the time. Check out the popularity of this post, describing a phenomenon many people seem to identify with. A manager trusting an advisor will introduce one check and balance, but it's hardly foolproof. It gets better when there is regular peer review and pairing. More checks, more balances, more eyes, and more voices.
But guess what? If we eliminate all evaluation options for managers with the exception of presiding over a team with extensive peer review, we're back to square one. It's going to be up to a member of the team without any authority over Bob to let Bob know that he needs to improve his code. It's going to take conversations, persuasion, and collaboration, as opposed to management cracking the whip and sizing people up.
In the end, there's only one reliable way for management to ensure that there aren't Bobs out there, writing bad code indefinitely without feedback. They need to create a collaborative culture of positive feedback and trust so that the team of humans they're managing take care of one another and spur each other on toward improvement. Bob's bad code is the team's bad code, not management’s. And the team, not management, needs to own the code.
The State of Code Quality 2016
The State of Code Quality 2016 Report includes insights from 600 software developers, testers, IT/operations professionals, and business leaders representing more than 30 different industries. Participants in the survey work on software teams ranging from less than five employees to more than 50 employees, and work for companies ranging from small businesses, with less than 25 employees, to enterprise organizations, with 10,000 employees or more.
The following report will cover:
- Perceptions on Code Quality
- Approaches to Code Review
- Code Review Tools and Decision Making
- Software Development Tools
Get your copy!