Agile Zone is brought to you in partnership with:

Jens Schauder is software developer since 1997. He loves software development for the constant challenges and constantly changing environment. A great chance to learn and teach. He is also blogger, author of various articles and speaker at conferences. Jens is a DZone MVB and is not an employee of DZone and has posted 81 posts at DZone. You can read more from them at their website. View Full User Profile

Shu Ha Ri and Code Metrics

02.19.2013
| 4173 views |
  • submit to reddit
Code Metrics sure get mixed feelings by developers, especially when combined with thresholds to form checks that might make a CI build fail. Typical examples are:

Line based code coverage  must not fall below 80%.

A method must not be longer than 15 lines of code.


Arguments against such rules state there are cases where such checks limit the freedom of a developer.
During a discussion around these things it occurred to me that the metrics and checks come from a different skill level than the arguments against them.

Let me introduce Shuhari:

Shuhari is a Japanese martial arts concept describing the stages of learning to mastery.

Shu describes the strict adherence to rules as one does when one begins to learn. This is where metrics live. They are strict rules. As a practitioner you just follow the rules without really thinking about them.

Ha describes the bending, changing and breaking of rules, as you might do when you are quite experienced.

Ri finally is described as transcendence, i.e. the rules don’t really have a meaning to a master on this level. She just knows what to do.

I think one can easily see how metrics get in the way of a master at the higher levels. Right? But there is an interesting point in the short Wikipedia article for Shuhari:

Shuhari can be considered as concentric circles, with Shu within Ha, and both Shu and Ha within Ri. The fundamental techniques and knowledge do not change.


For me this means: While a master can and will break rules at will, most of the time she won’t because the rules align with what is the right thing to do ™.

So if you think those code metrics are stupid and shouldn’t apply to your code, you are welcome to prove to me that you are a Ri level master (I’m certainly not). A first indicator would be that you can follow those rules without them actually being enforced.

But if you are constantly breaking builds due to Checkstyle, PMD and Sonar violations, you are not demonstrating mastership but sloppy working.
Published at DZone with permission of Jens Schauder, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: