Hi , this algorithm diffecult to implement and work ,how can i write code for this because ,i write code for it but isnt work completely to find CBO i.e Eff.size.

Input: Any class file
Output: Total coupling in the class file
/*Eff is set for efferent coupling(set is java collection which holds only unique
values), i is the index used, Interface contains the number of interfaces, Field contains
the number of fields, Method contains the number of methods, filename is the name of
input file, argumentstype is the type of argument, exceptiontype is the type of
exception. Here class is being iterated using an API bcel.jar*/
1. Select a java class file and parse it using bcel API. //bcel parses it and creates
objects of class
2. Set: filename = inputfilename;
3. Traverse the class.
4. foreach Interface ϵ class do
registerCoupling (Interface);
endfor
5. foreach Field ϵ class do
registerCoupling (Field.returntype);
endfor
6. foreach Method ϵ class do //Identify different classes based on arguments,
returntypes
registerCoupling (Method.returntype);
registerCoupling (Method.argumentstype);
registerCoupling (Method.exceptiontype);
registerCoupling (Method.localargumentstype);

foreach MethodInstruction
/* if conditions can be determined by using api bcel.jar and calling its api*/
if (instruction instanceof LocalVariableInstruction)
registerCoupling (LocalVariableInstruction type);
endif
if (instruction instanceof ArrayInstruction)
registerCoupling (ArrayInstruction type);
endif
if (instruction instanceof FieldInstruction)
registerCoupling (FieldInstruction type);
endif
if (instruction instanceof InvokeInstruction)
registerCoupling (InvokeInstruction type);
endif
if (instruction instanceof INSTANCEOF)
registerCoupling (INSTANCEOF type);
endif
if (instruction instanceof CHECKCAST)
registerCoupling (CHECKCASTtype);
endif
endfor
endfor
7. Return Eff.size();

Methods definition:
registerCoupling (Type t){
registerCoupling (className(t))
}
className(Type t){
if (t is premetive)
return;
endif
if (t is array type)
return;
endif
return name of type t ;
/*in java it can be t.tostring()*/
}
registerCoupling (String classname){
if (classname is javaclass or classname is filename)
return;
endif
/*Add to set*/
Eff.add (classname)
}

what "does not work"? can you distinguish between requirements - pseudocode - actual code,
say what works, what fails, any error message, where the exact problem is, ...

So.. I will write my code for this algorithm ...please read my code and help me to find solution...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.