PHP Depend - Software Metrics for PHP

Abstraction Instability Chart

:Author: Manuel Pichler :Copyright: All rights reserved :Description: This document gives a detailed description of the abstraction instability chart that can be generated with PHP_Depend. This chart provides an abstract view on the code structure of a whole project. This chart implementation is based on a whitepaper published by Robert C. Martin in 1994. :Keywords: Main Sequence, Abstraction, Instability, Distance, Quality, Robert C. Martin, Dependencies, Abstract classes, Concrete classes

To provide a flexible and extendable software, it is a good OO practice to reduce the dependencies between implementing classes. This could be achieved by developing against abstractions which means both, abstract classes and interfaces. By using abstractions instead of real implementation in the application you provide some sort of contract, that could be used by others to hook into the application with their own classes that fulfill the contract. Except the extensibility of an application a good abstraction reduces the risk of breaks in multiple subsystems when something was changed in a single package. But how to get rid of all these dependencies, doing this by hand will become an impossible job, at least for larger projects. At this point a tool should be used to assist the development process.

The A-I chart as it is generated by PHP_Depend is based on the whitepaper OO Design Quality Metrics - An Analysis of Dependencies [#ubmoodqm]_
published by Robert C. Martin. It shows you the quality of your design in the terms of extensibility, reusability and maintainability. All these facts are influenced by the inter-package dependencies and the package abstraction that PHP_Depend visualizes in form of an abstract/instability chart.

PHP_Depend calculates the following metrics by counting classes, interfaces and dependencies.

With these values we can create a chart that visualizes the relationship between the instability (I) on the y-axis and the abstraction (A) on the x-axis.

Graphical view of PHP_Depend's metrics

Because in a project not each package can achieve the optimal values of A = 1, I = 0 or A = 0, I = 1, we draw a diagonal between the two corners. This line is called the Main sequence and represents an average between abstraction (A) and instability (I). This means that packages near this line have a good mix between abstraction and instability. You can call these packages balanced. Because it is desirable for packages to be
close to the Main sequence we have a fifth metric, the package distance (D) from this ideal.

OO Design Quality Metrics - An Analysis of Dependencies; Robert C. Martin; 1994

Reports

Overview Pyramid