Advances in Information Science and Applications - Volume II

Implementation for Model of Object Oriented Class Cohesion Metric -MCCM Tejdeda Alhussen Alhadi Dr. Omer Saleh Xavier Patrick Kishore Sagaya Aurelia [email protected] [email protected] [email protected] [email protected] Department of Faculty of Education Beniwalid, Libya

II. E1B NVIRONMENT Abstract—Class cohesion should not exclusively be based on common instance variables usage criteria. Method Connectivity The Java runtime environment (JRE) is required in Cohesion Metric (MCCM) uses both direct and indirect method order to run (MCCM.jar). We have also used Eclipse (SDK relations (attributes usage criterion and methods invocation 3.1) which is a kind of universal tool platform-an open criterion) in its calculations [1]. This paper presents a tool to extensible IDE for anything and nothing in particular. It measure MCCM (Method Connectivity Cohesion Metric) that provides a feature rich development environment that allows measures the cohesion of classes coded by Java programming the developer to efficiently create tools that integrate language. The major motivation is to carry out this study that seamlessly in Eclipse platform [2]. The jar file is directly computes the class cohesion and comparison between MCCM metric and LCC. executable by Eclipse SDK program.

Keywords—MCCM; Cohesion; Method Invocation; Attribute A.2B MCCM Metric Architecture Usage MCCM metric is a software metrics tool that measures the structural properties of java code and computes a number of I. INTRODUCTION software measures that include cohesion and coupling. There are lots of metrics for coupling and cohesion in the literature, for the estimation of class cohesion is based on different relationships that may exist between its methods. It takes into account several ways of capturing the functional Class .Jar cohesion of the class, by focusing on Connectivity between File File methods [1]. The MCCM tool measures the quality of the entrance program by the user, Then entrance program is analyzed to classes, these classes are measured its cohesion and coupling of each class separately by the used metric (MCCM). Class Jar Finally, (MCCM) tool presents the results of cohesion and Parser parser coupling of each class, to make the programmed able to modify any class has non-satisfactory results in order to reach the highest quality. Data Repository

Quality Goals

MCCM Metric Calculation

Tool Tool High Cohesion (MCCM Metric) Low Coupling

Cohesion Coupling

Results Repository Entrance

program  Fig.2. MCCM Metric Architecture User Interface Results

Fig.1. Overview of MCCM Implementation As shown in Fig.2, object-oriented systems are parsed to the tool in order to collect the data that can be used in computing

ISBN: 978-1-61804-237-8 576 Advances in Information Science and Applications - Volume II the various software metrics supported by the tool. The data collected are stored in central data repository and results in result repository.

B.Flow Chart of (MCCM) Tool

Start

Input

Find the No, of Attributes & No, of Methods Fig(4) main page of MCCM software.

A. Analyzing the file

file chosen in the first step will be listed. To analyze which is the second section of this program, right click on file (.class Check the or .jar) and select Analyze. Connection Indirect Type Direct

Calculate Indirect Calculate Direct Connection (MI& AU) Connection (MI& AU)

Calculate MCCM

Display Results Fig.5. Screen Capture of Analysis the file

End B.Examining the results

The results will be listed in the output section, the third Fig.3. Flow Chart of (MCCM) Tool section of this program.

III. USING MCCM MEASUREMENT TOOL This program has three main sections: A. Input Section B. Analyze Section C. Output Section

Fig.6.Screen Capture of Exporting the results

ISBN: 978-1-61804-237-8 577 Advances in Information Science and Applications - Volume II

IV. THE EVALUATION

In order to complete the project and make it ready for the M1 M2 M3 user it should undergo an evaluation process to confirm that MCCM tool fulfills the proposed objectives and demonstration of the software. a1 a2 A. ConnectivityCriteria

In this section will calculate for each connectivity (Direct / Indirect) mathematical MCCM value [1] and the compare with MCCM tool value. The table (1) shows the results of this comparison.

TABLE 1 CONNECTIVITY CRITERIA B.Selected System

From a total of six projects, three projects were

MCCM MCCM collected from www.projectsparadise.com, and other projects (Mathematical Calculation) (Metric Output) from SourceForge.net which are an open source websites that provides a centralized space where open source developers can

control and manage open source software development [3] [4]. M M TABLE 2 DETAILS OF THE PROJECTS

M No of No of No of Project Classes methods Attributes bluej-307 7 86 245 car_sales_system 11 102 323 LibraryManagementSystem 29 570 340 checkstyle-all-2.4 78 492 228 jgraph-5.10.2.0 50 750 340 Saxon9he 107 1252 876

C.Snapshot of Output of Projects Using MCCM Tool:

M M TABLE 3 SNAPSHOT OF OUTPUT

Project M Class name LCOM LCC MCCM COUPLING name

Bluej Org.apache.log4j.chain 1 0.11 0.33 0.67 saw.controlPanel$1 -

307.jar Org.apache.log4j.chain 1 0.32 0.33 0.67 saw.controlPanel$2 Org.apache.log4j.chain 100 0.02 0.33 0.67 saw.controlPanel$3 Car_sale system AboutDialog 4 0.08 0.88 0.12

_ AddCarPanel 7 0.15 0.83 0.17

Car 77 0.01 0.88 0.12 managm Library system M1 M2 M3 ent AddBooks 12 0.01 0.93 0.07 AddMembers 3 0.04 0.88 0.12

Books 102 0.0 0.92 0.08 Antlr.ANTLRHashStri 4 4 0.42 0.68 0.32 Checkstyle.jar ng Antlr.ANTLRStringBu 0 0 0.37 0.5 0.5 a1 a2 ffer Antlr.ASTFactory 89 0.3 0.92 0.08 Antlr.ASTPair 0 0.27 0.5 0.5 Antlr.BaseAST 504 0.02 0.93 0.07

Antlr.CHarQueue 0 0.66 0.35 0.65 Jgrap

.jar h Org.jgraph.event.Grap 0 0.41 0.25 0.75

hSelectionEvent

ISBN: 978-1-61804-237-8 578 Advances in Information Science and Applications - Volume II

Org.jgraph.AbstractCe 383 0.07 0.85 0.15 • The cohesion value of the LCOM metric in class llView (CarsCollection) equals (0.0), and the cohesion value of Org.jgraph.graph.Attri 325 0.03 1.0 0.0 buteMap the MCCM metric equals (0.68). The cohesion value of Org.jgraph.graph.Basi the LCOM metric in class (SearchByOtherpanel) equals 88 0.07 0.75 0.25 cMarqueeHandler (0.0), and the cohesion value of the MCCM metric equals Org.jgraph.graph.Conn 9 9 0.11 0.66 0.34 (0.77). The cohesion value of the LCOM metric in class ectionSet$Connection Org.jgraph.graph.Conn (ShowAllCarpanel) equals (0.0), and the cohesion value of 30 0.46 0.5 0.5 ectionSet the MCCM metric equals (0.62). Where LCOM metric Javax.xml.xquery.XQ gives zero value, MCCM metric gives values which are 1 1 0.0 1.0 0.0 Constant higher than zero. So not all the connection types between Javax.xml.XQQueryE 2 2 0.1 0.71 0.29 elements in a class are taken into account in LCOM xception Saxon9he.jar metric. Javax.xml.xquery.XQ 0 0 0.22 0.5 0.5 StackTraceVariable • The coupling values of all classes are low, as we know the Net.sf.saxon.dom.Attr 46 0.09 0.63 0.37 OverNodeInfo maximum value of coupling is one. For example: coupling

Net.sf.saxon.dom.Doc of class (Car) equals (0.12), and coupling of class umentBuilderFactoryI 17 0.13 0.7 0.3 mpI Metric Interaction Type Interaction Mode Method Interaction Net.sf.saxon.dom.Doc 15 0.18 0.61 0.39 M/ A/ M A M M Direct Indirect umentBuilderImpI Invocation Sharing

LCOM √ √ √ D.Results and Analysis LCC √ √ √ √

MCCM √ √ √ √ √ √ TABLE (4) RESULTS OF (CAR_SALES_SYSTEM.JAR) (Welcomepanel) equals (0.31).

Project Class name LCOM LCC MCCM Coupling Through this explanation we results that the above tables name prove that MCCM metric tool always has high cohesion and AboutDialog 4 0.08 0.88 0.12 low AddCarpanel 7 0.15 0.83 0.17 coupling. The result states that MCCM metric always returns Car 77 0.01 0.88 0.12 higher values comparing to LCC because, all the connection

car_sales_system CarDrtailsComponents 21 0.05 0.85 0.15 type between elements in the classes are taken under CarSalesSystem 130 0.02 0.95 0.05 consideration. Moreover, Cohesion refers to the degree of the CarsCollection 0 0.23 0.68 0.32 relatedness of the members in a component. High cohesion is a desirable property of software components. It is widely Manufacturer 3 0.19 0.58 0.42 recognized that highly cohesive components tend to have high SearchByAgepanel 0 0.26 0.72 0.28 maintainability and reusability. SearchByOtherpanel 0 0.22 0.77 0.23 ShowAllCarpanel 0 0.34 0.62 0.38 E. Comparison between two projects Welcomepanel 0 0.41 0.69 0.31 This section presents measuring and comparison the quality of two projects by using MCCM tool. In this section we present the analysis of the results using MCCM tool, and Comparison between LCOM metric, LCC • First project (car_sales_system.jar) metric and MCCM metric. Table (4) shows the results of metrics calculation under mentioned project using LCOM, LCC and our proposed metrics for class cohesion MCCM and we can interpret the results as follows: • The cohesion value of the LCC metric in class (AboutDialog) equals (0.08), and the cohesion value of the MCCM metric equals (0.88). The cohesion value of the LCC metric in class (AddCarpanel) equals (0.15), and the cohesion value of the MCCM metric equals (0.83). The cohesion value of the LCC metric in class (SearchByAgepanel) equals (0.26), and the cohesion value of the MCCM metric equals (0.72). We can notice that the MCCM metric tool gives higher value more than LCC metric value.

ISBN: 978-1-61804-237-8 579 Advances in Information Science and Applications - Volume II

• The most effective Interaction Type is M → M. This may be considered as the best way to capture the cohesion of a class because methods play a better role (than attributes) in determining what the functionality of a class. • It is interesting to note that with the mechanisms presented in Table (5), the cohesion metrics correlations can easily be explained. For instance: MCCM use all the stronger interaction type and interaction mode, whereas LCC does not.

V. C5B ONCLUSION We have developed a cohesion measurement tool for Java software to automate the computation of the major existing class cohesion metrics including ours. In order to demonstrate the effectiveness of the MCCM cohesion metric, we performed a case study on several systems.

The obtained results confirm our hypothesis. They show Fig.7.Results of car_sales_system.jar clearly that the MCCM metrics, based on a combinationof the

proposed criteria, capture more pairs of connected methods • Second project (Bluej-307.jar) than the existing cohesion metrics, particularly the ones supposed implicitlytaking into account the interactions between methods (Method Invocation and Attribute Usage). We believe that the present work constitutes an improvement of class cohesion assessment.

R7B EFERENCES [1] Tejdeda Alhussen Alhadi, Dr Omer Jomah, Xavier Patrick kishore, Sagaya Aurelia, Mathematical Model of Object Oriented Class Cohesion Metric MCCM, unpublished [2]Lars Vogel, “Eclipse JFace Overview”, Version 2.7, October 2012, From http://www.eclips.org/platform,. [3] H. S. Chae, Y. R. Kwon and D H. Bae, A cohesion measure for object-oriented classes, Software Practice and Experience, No. 30, pp. 1405-1431, 2000. [4] Al Dallal, J. and Morasca, S., Predicting Object-Oriented Class Reusability Using Internal Quality Attributes, Empirical

Software Engineering, in press, 2012. Fig.8.Results of Bluej-307.jar [5] Abubakar A., “Implementation and validation of object- The displayed results in the above figures explaining, the first oriented design –Level cohesion metrics”, Thesis presented, project (car_sales_system.jar) has higher value in (MCCM Dhahran, Saudi Arabia, Computer Science, January 2005. column) more than the second project (Bluej-307.jar), and has value in (Coupling column) is less than the second project Ms. Tejdeda Alhussen Alhadi (Feburary 1, 1980) is now (Bluej-307.jar). So we conclude that the first project with Faculty of Education, Azzaytuna University, Bani-walid, (car_sales_system.jar) has higher quality more than the second Libya. She is into teaching profession for more than 13 years. project (Bluej-307.jar), because all classes in the first project She has done B.Sc and M.Sc in Computer Science from (car_sales_system.jar) have high cohesion and low coupling, Libyan Academy. She has also been involved in various and all classes in the second project (Bluej-307.jar) have low administration related activities. Her specialization includes cohesion and high coupling. Database, Software Engineering and Artifical intelligence. She has published various national and international papers and These mechanisms are presented in Table (5) along with the guided many projects. cohesion metrics [5]. Dr. Omer Saleh Mahmod Jamah (January 25,1973) is now the Director of Post graduate From Table (5) the following conclusions are drawn: cum Research and Development and Head of • There are two ways via which`h the interactions among the department of Computer science, Faculty methods can be captured : of education, Azzaytuna university, Baniwalid, (1) Method Invocation (2) Attribute sharing. Libya. He received his B.Sc. in Control

ISBN: 978-1-61804-237-8 580 Advances in Information Science and Applications - Volume II

System and Measurement (1995), M.Sc. in Electrical and Computer Measurement (2004), and Ph.D. in , Automatics computer science and electronics from AGH University of technology, Krakow, Poland. He has done his in Planning and time from Canada Global Centre, Canada. Now he is heading Computer Science department, Faculty of Education, Azzaytuna University, Baniwalid, Libya. His research interest includes multicriteria optimization for solving optimal control problems and Fuzzy logic. He has published 12 papers and attended various national and international Level conferences and workshops. Mr. Xavier Patrick Kishore (November 6, 1973) received his BSc Mathematics (1994), Master of Computer Application (2002) and in E-Commerce and Advanced software Technology. He has received Brain bench certification in Java and HTML. Now he is working in Department of computer science Faculty of Education, Azzaytuna University,Baniwalid, Libya. He is specializedin programming languages. His current research interest includes Natural languageprocessing. He has authored more than 9 papers and attended many conferences. Er. Mrs. Sagaya Aurelia(November 9,1978) par-time research scholar in Bharathidasan university . Now she is with department of Computer Science, Faculty of Education, Azzaytuna University, Bani-walid, Libya. She received her Diploma in Electronics and Communication (1997),B.E (Bachelor of Engineering specialized in Electronics and Communication Engineering(2000) and M.Tech in Information Technology(2004),she has also done her Postgraduation diplomasinBusiness Administration (PGDBA) and Journalism and Mass Communication(PGDJMC). She has received Brainbench certification in HTML. Her current research interest includes Virtual reality, Augmented reality and Human Computer Interaction and User interface Design. She has authored14 papers and attendance several national and international level workshops and conferences.

ISBN: 978-1-61804-237-8 581