Domanda

I'm reading a scientific paper about OO Design Quality Metrics written by Robert martin.

In his paper he describes "a set of metrics that can be used to measure the quality of an object-oriented design in terms of the interdependence between the subsystems of that design"

He goes on about how there should be a good balance between abstraction and instability. Here are the metrics he writes about and how they can be calculated:

Na: The number of concrete and abstract classes (and interfaces) in the package is an indicator of the extensibility of the package.

Afferent Couplings (Ca): The number of classes outside the package that depend upon classes within the package.

Efferent Couplings (Ce): The number of classes inside the package that depend upon classes outside the package.

Abstractness (A): The ratio of the number of abstract classes (and interfaces) in the analyzed package to the total number of classes in the analyzed package. The range for this metric is 0 to 1, with A=0 indicating a completely concrete package and A=1 indicating a completely abstract package.

Instability (I): The ratio of efferent coupling (Ce) to total coupling (Ce + Ca) such that I = Ce / (Ce + Ca). This metric is an indicator of the package's resilience to change. The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely unstable package.

Distance from the Main Sequence (D): The perpendicular distance of a package from the idealized line A + I = 1. This metric is an indicator of the package's balance between abstractness and stability. A package squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal packages are either completely abstract and stable (x=0, y=1) or completely concrete and unstable (x=1, y=0). The range for this metric is 0 to 1, with D=0 indicating a package that is coincident with the main sequence and D=1 indicating a package that is as far from the main sequence as possible.

I made the following simple design.

enter image description here

I'm confuse about the last metric (D). If I calculate the metric D(D' in the picture), I get a negative value of -0.5. But if I read the description is says the value should be between 0 and 1. Also wikipedia states that for metric interfaces are also considered as abstract classes. But I can't make this up from the paper. Is this true?

enter image description here

Did I do something wrong? Is believe this design, although really small, isn't that bad right?

È stato utile?

Soluzione

If D is "distance" then you should consider its absolute value, the formula in the paper has an absolute operator also... I'm not sure how you calculate the distance, or I misunderstood you.

About considering abstract class and interface I think both of them are mechanisms to provide an "Interface Framework", which means keeping dependencies in the interface level not the concrete classes... so I think it's safe to consider them the same thing despite some differences.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top