“As far as code quality is concerned, my favorite measure is Cyclomatic Complexity or rather a variation called, “Crap,” says well-known software guru and author, “Uncle Bob” Martin. Martin explains what Cyclomatic Complexity is and answers other questions about his new book, The Clean Coder, in this second part of a two-part interview. Read part one.
SSQ: Though you note that it’s a generalization with exceptions, you say, ‘the reality is that programmers do not tend to be collaborators.” Is there a place in Agile development for developers who prefer working independently rather than in teams?
Martin: Lone wolves are at a pretty steep disadvantage in a team environment. A reasonably large team might find a slot for the occasional loner, perhaps as a tool smith, or a script writer; but the vast majority of work is done within the team.
SSQ: You say, “No professional developer should ever follow a discipline when that discipline does more harm than good.” However, there may be differing opinions about whether that discipline is doing harm or good. Let’s take the question above as an example. Let’s say there’s a developer who is a very strong coder, but he is an introvert and is much more productive when working alone. He might claim that being part of an Agile team is doing more harm than good. While others may point out that Agile teams and collaboration is a better way to work, for him, this may not be true. Who decides whether a discipline is doing more harm than good?
Martin: The team decides which disciplines they will follow. The introvert who disagrees will not find it very comfortable on that team, and may need to leave, or even be expelled.
SSQ: You advise “practicing” and learning new technologies by volunteering to help with open source projects. However, is discipline monitored in these cases? If a developer is just learning a new technology and has no worries about getting a poor review, isn’t he or she more likely to cut corners and produce poor code?
Martin: Most open source projects are pretty tightly controlled. The committers review all the code produced by contributors, and reject the code that is of poor quality. So contributing to open source projects is a good way to be mentored.
SSQ: I’ve recently been talking to a number of experts who have differing viewpoints on the merits of defect tracking throughout the development life cycle. What are your thoughts on this?
Martin: I don’t mind defect tracking so long as the number of defects stays very close to zero. I don’t want defect tracking used as an excuse for allowing high levels of defects.
SSQ: What do you think is the best way to measure the quality of an application?
Martin: As far as code quality is concerned, my favorite measure is Cyclomatic Complexity or rather a variation called, “Crap.” This metric is the ratio of Cyclomatic Complexity and Unit Test Coverage computed on a function by function basis. A function that has high test coverage and low CC scores well. A function with low coverage and low CC scores medium. A function with high CC and low test coverage scores horribly.
But the real test of code quality is customer satisfaction; and this comes in two forms: current satisfaction, and long term satisfaction. In other words, does the customer like it now, and will the customer like it a year from now? It’s relatively easy to get the first at the expense of the second. A professional software team makes sure that future quality is not held hostage to current schedule.
SSQ: What do you think is the most important takeaway readers will get from your book?
Martin: There is a single bit that I want flipped in everyone’s head. If that bit gets flipped, then all the other things we’ve talked about will fall into place. That bit is the one that says: “The only way to go fast, is to go well.”
This Q&A is based on the book, The Clean Coder: A Code of Conduct for Professional Programmersby Bob Martin, published by Pearson/Prentice Hall Professional, ISBN 0137081073, Copyright 2011 Pearson Education, Inc. For more info please visit: www.informit.com/title/0137081073