A VF-IMF Cohesion Metric for Object-Oriented Classes

Cohesion in Object Oriented (OO) modules impact reusability, efficiency and complexity of software. OO Programmers are mandated to create software with high cohesion. The testing phase in Software Development Life Cycle (SDLC) is not only concerned about creating error free software but also assess quality of code through software metrics. The metric‘Lack of Cohesion in Methods (LCOM)’ is one of the significant OO metric for measuring level of cohesion in software modules. LCOM and its improvised versions of cohesion metrics output degree of cohesion in software modules rather than providing solutions to reconstruct the poorly cohesive modules. Further, the traditional cohesion metrics do not differentiate the possible levels such as high, medium and low cohesions. Thus, in this paper a novel, Variable Frequency – Inverse Method Frequency (VF-IMF) based machine learning metric is proposed to assess the level of cohesion in modules and also to group module methods to instill high cohesion. The proposed metric is experimented over three sample modules represents each level of cohesion. The experimental results show that the proposed metric clearly differentiates the three levels of cohesion and offers a compromised solution for building high cohesive modules than traditional LCOM metrics. The metric is also validated against Weyuker’s properties and is proven to be a valid metric as it satisfies all the 9 properties.