Open GoogleCodeExporter opened 9 years ago
Another alternative would be to leave the current implementation and storage of
metrics as a simple int[] and to write a wrapper class for performing metric
comparison. i.e. Some sort of utility class.
This would also have to perform the distance comparisons, number of modified
metrics
etc. To support this, a new enum would be created to configure which metrics
are
compared in such comparisons.
MetricType.COMPARATIVE,
MetricType.DISTANCE;
class MetricUtil()
{
// Compares the entire contents of the two metric sets for equality.
public static boolean equal(int[] metrics, int[] metrics2);
// Compares the 'type' contents of the two metric sets for equality.
public static boolean equal(int[] metrics, int[] metrics2, MetricType type);
// The distance from metrics to metrics2
public static double distanceFrom(int[] metrics, int[] metrics2);
// The distance from metrics and metrics2, using MetricType for comparison.
public static double distanceFrom(int[] metrics, int[] metrics2, MetricType type);
// The number of different metrics between metrics and metrics2
public static int modifiedMetrics(int[] metrics, int[] metrics2);
// The number of different metrics (that are of the specified type)
// between metrics and metrics2
public static int modifiedMetrics(int[] metrics, int[] metrics2, MetricType type);
}
Using an example from the initial issue article the class would use the utility
to
perform the comparison instead of doing it itself.
Example 2:
// This should compute the distance moved from cmd to cmd2. This should be
// performed only on distance computation metrics.
public double distanceFrom(ClassMetricData cmd, ClassMetricData cmd2)
{
return MetricUtils.distanceFrom(cmd.getMetrics(), cmd2.getMetrics(),
MetricType.DISTANCE);
}
Original comment by jtha...@gmail.com
on 31 Aug 2007 at 6:50
After further thought I think I will implement the metric utility class. Whilst
enums in Java are glorified classes that can easily encapsulate all this
information
from an implementation point of view the utility class will be easier to
implement
because it has no impact on the rest of the system added as is.
Changing the metric representation at the storage level would proliferate
changes
through other parts of the systems such as persistence.
Original comment by jtha...@gmail.com
on 31 Aug 2007 at 6:58
Looking at the two groupings of metrics in build001 I'm puzzled as to how they
were
made.
I am referring to...
public final String[] metrics = {"branchCount", ...}
public final String[] distanceComputationMetrics = {"branchCount", ...}
For example, the metrics staticMethodCount, sycnrhonizedMethodCount and
finalMethodCount are not part of the distanceComputationmetrics. But
abstractMethodCount is. This seems odd, is this a mistake?
These lists have not been updated with any of the newer metrics that have been
added. Is this on purpose? There are many, many metrics not in either set and
are
thus not looked at during metric comparisons. Some of which, seem that they
should
be used during class equality/clone checks for example.
So far I am treating them as follows....
MetricType.COMPARATIVE // Only in the comparative metric set
MetricType.DISTANCE // Only in the distannce metric set.
MetricType.ANY // In both
MetricType.NOT_COMPARABLE // Not used for comparison purposes.
Original comment by jtha...@gmail.com
on 31 Aug 2007 at 7:31
Original issue reported on code.google.com by
jtha...@gmail.com
on 31 Aug 2007 at 6:27