Best metric available

L

lavanya.msra

Hi All,

What is the today best metric standard available to measure coupling
of JAVA code?

regards,
Lavanya M.
 
L

lavanya.msra

Google turns uphttp://www.virtualmachinery.com/jhawkmetricsclass.htm

If by best you mean "easily found using Google" then perhaps this is the
best. Otherwise you might find it helpful to tell us what "best" means
to you.

If you have patience, a real expert in this field might read your
question and provide a more authoritative reply.

Good luck.

Using google I could find that for measuring Cohesion LCOM is perhaps
most commonly used industry practised way of measuring coupling.
But for measuring coupling could not find any such commonly accepted
standard.

Ok. I just looked into url provided. And it indeed is very helpful.

regards,
Lavanya M.
 
A

Arved Sandstrom

Hi All,

What is the today best metric standard available to measure coupling
of JAVA code?

regards,
Lavanya M.

Typical coupling metrics are (and no single one is the "best"):

1) Coupling Between Objects (CBO): this is the number of classes to which
the class being measured is coupled, by accessing a method or instance
variable of the other class(es). Include all classes to which the call could
go because of polymorphism. Treat inheritance as regular coupling for CBO
purposes (** some definitions say exclude these - it's up to you). If the
method call is simply an implementation of an interface this doesn't count;

2) Data Abstraction Coupling (DAC): the number of attributes in your
measured class that have another class as their type. DACd is the number of
different other classes used as types by your class. This does not include
interfaces (since using them is a good thing), and use your judgment as to
classes external to your project. Strictly speaking what you're looking for
is the number of different instantiations of other classes in the measured
class, so locals are included;

3) Number of Foreign Methods Accessed (NFMA): for a method, how many methods
does it invoke that belong to other classes? For a class, the sum of the
previous. Note that in both cases multiple occurrences are counted once.
Inherited method calls may or may not be counted - just document which one
you do;

4) Method Invocation Coupling (MIC): the relative number of classes that
receive messages from your measured class. A ratio in other words.

There is also the COF, Coupling Factor, which is another relative
coefficient.

It's the interpretation of any of the above that is key. For example, data
abstraction is good...to an extent. I've seen projects where the developers
went apeshit creating classes for every logical data type, and all that
added was dozens of different String types and the like. That would get
dinged by a DAC metric, and IMHO rightfully so. But in another situation
exactly the same number might be OK, if the classes referenced genuinely had
a decent purpose.

You might also be interested in reading about the Law of Demeter. I can see
the argument - if you're going to invoke a method on an object you should
have a direct reference to it, rather than getting it through a method call
on yet another object, but in practise this is not followed much.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top