What makes software source code good? Is it the use of some clever logic or algorithm? A minimal number of lines of code? Or perfect formatting? Different developers will have different answers to that question, of course, but a new, informal survey finds that the number one quality of good code is simply that it’s easy to read and understand.
This result was published recently by Intent HQ, a U.K.-based company that specializes in audience intelligence (also, Intent HQ is a partner of IDG, ITworld’s parent company). Over the past four years, Intent HQ’s Head of Engineering Albert Pastrana has interviewed many candidates for developer positions. As part of the interview process, he’s asked each one the same question: How would you define good code?
I contacted Intent HQ to find out what the company learns by asking this question of prospective developers. “One of our primary objectives is to get to know more about that person, about his/her opinions and about what she hates and what he loves,” Pastrana told me via email. “With it, we can see what the candidate subjectively believes about developing and, in many cases, we learn a lot about their past experiences (and sometimes traumas)!”
Recently, he looked at the answers given by 65 developer candidates who were interviewed over the course of 2014; all were programmers with knowledge of Java or Scala and had five or more years of experience. After grouping similar answers together, to Pastrana’s surprise, the number one quality of good code was, by far, readability, mentioned by 78% of interviewees.
Interestingly, other code qualities that Pastrana and his colleagues had presupposed would be ranked higher lagged well behind, such as whether the code actually works (tied for 3rd, mentioned by 25% of respondents) or is easily maintainable (5th, 22%). The rest of the top five answers provided were code that’s testable (2nd, 29%) and simple (tied for 3rd, 25%). Other notable qualities that ranked lower include code that’s documented (18%), extendable/reusable (18%), efficient (12%), and concise (6%).
Based on these results, the company came up with the following definition of good code:
“Good code is written so that is readable, understandable, covered by automated tests, not over complicated and does well what is intended to do.”
I asked Pastrana if he will continue asking this question of potential programming hires (he will) and how (if at all) the answers have informed their hiring process. “If the results have influenced our hiring process at all, it's simply that it has allowed us to be more precise about the types of traits we're looking for in candidates,” he wrote. “As a team, we already had our notion of what ‘good code’ was, but having a central definition to share between us all allows for consistency during an interview.”
The answer to the question “How would you define good code?” that most made Pastrana smile? “Tested, and it doesn’t explode.” “I think most developers have been in that situation (in front of a piece of code that simply explodes) at some point throughout their careers,” he told me.