Implementation for Model of Object Oriented Class Cohesion Metric -MCCM Tejdeda Alhussen Alhadi Dr
Total Page:16
File Type:pdf, Size:1020Kb
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 Computer Science 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 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 h .jar 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).