HTTPS SSH

ABsolute PRIority COUnter (abpricou)

abpricou parses Java source code and counts its mass as defined by the Absolute Priority Premise. It is written in Python and has the awesome plyj and PLY as its sole dependencies.

Absolute Priority Premise

In 2012 Micah Martin defined some heuristics to objectively say, "This code is better than that code." Building on Uncle Bob's Transformation Priority Premise he defined six components, i.e. basic building blocks of code, and assigned them a mass. The total mass of a piece of code is the sum of the mass of its respective components. A lower value is better.

A detailed explanation of the Absolute Priority Premise is given in the two presentations of 8th Light University (8LU) - Part One and Part Two. See also Micah's Coin Changer Kata as a complete example of applying the premise.

Limitations

  • abpricou currently supports Java 7 due to limitations of plyj.
  • I developed it to count the mass of a specific set of classes. No exhaustive tests have been done. If you find something that us not counted, please get in touch.
  • I was interested in the mass of algorithms, so class constructs like class definitions are ignored. Probably a class definition is a constant (for the code) and a binding (for the name). Also enums and all annotations as well as generics were ignored.
  • Counting mass depends on opinion. You may count different. If so, please get in touch.

Example

I used abpricou to compare different implementations of Word Wrap kata in my blog post Absolute Priority Premise, an Example.

License

abpricou's license is the New BSD License, see license.txt in this repository. Both plyj and PLY are also BSD licensed.