EPL 603 TOPICS IN SOFTWARE ENGINEERING Lab 5: Component Adaptation Environment (COPE)
Performing Static Analysis 1 Class Name: The fully qualified name of the specific class Type: The type of the class (e.g. Class, Abstract Class, Interface, etc.) Size: The size of the specific class (in bytes) Used By: Number of classes in the project that uses the specific class Uses (I): Number of internal classes used by the specific class Uses (E): Number of external classes used by the specific class Layer: The layer of the class CKJM: Chidamber and Kemerer Java metrics R (reusability index): It is an estimation of the reusability of a class based on the Chidamber-Kemerer metrics. The larger this value the more reusable a class is. It can take values between 3 to -20 (approximately) Pattern: The design pattern to which a specific class is involved (if any) Cluster Size: The number of classes the specific class needs in order to form an autonomous, fully functional component. This is the cardinality of the dependencies' set of a class, which includes the class dependencies, the dependencies of these dependencies and so on
Chidamber & Kemerer Java Metrics 2 WMC Weighted methods per class denotes the sum of the complexities of its methods. The ckjm program assigns a complexity value of 1 to each method, and therefore the value of the WMC is equal to the number of methods in the class DIT Depth of Inheritance Tree provides for each class a measure of the inheritance levels from the object hierarchy top. In Java where all classes inherit Object the minimum value of DIT is 1 NOC Number of Children simply measures the number of immediate descendants of the class. CBO Coupling between Object Classes represents the number of classes coupled to a given class (efferent couplings, Ce). This coupling can occur through method calls, field accesses, inheritance, arguments, return types, and exceptions RFC Response for a Class measures the number of different methods that can be executed when an object of that class receives a message (when a method is invoked for that object) LCOM Lack of Cohesion in Methods counts the sets of methods in a class that are not related through the sharing of some of the class's fields Ca Afferent Couplings is a measure of how many other classes use the specific class. Ca is calculated using the same definition as that used for calculating CBO (Ce) NPM Number of Public Methods simply counts all the methods in a class that are declared as public. It can be used to measure the size of an API provided by a package
Weighted Methods per Class 3 Ένας μεγάλος αριθμός (πολύπλοκων) μεθόδων μέσα σε μια κλάση θα χρειαστεί περισσότερη προσπάθεια για να τα κατανοήσουμε Ένας μεγάλος αριθμός μεθόδων θα έχει ως αποτέλεσμα μια πιο πολύπλοκη συμπεριφορά των παιδιών της που κληρονομούν αυτές τις μεθόδους Μια τέτοια κλάση πολύ πιθανόν να είναι application specific και άρα λιγότερο επαναχρησιμοποιήσιμη Αποφεύγουμε κλάσεις με ψηλό WMC
Depth of Inheritance Tree 4 Κλάσεις με ψηλό DIT κληρονομούν μεθόδους από πολλούς προγόνους έτσι είναι πιο δύσκολο να προβλέψουμε τη συμπεριφορά τους και να δυσκολεύεται η συντήρηση τους Στη JAVA όλες οι κλάσεις κληρονομούν από το Object DIT = 1 Στη C++, το DIT μπορεί να είναι 0
Number of Children 5 Μια κλάση με μεγάλο αριθμό παιδιών μάλλον είναι θεμελιώδες στοιχείο στη δομή του συστήματος Κλάσεις με παιδιά είναι ξεκάθαρη υπόδειξη επαναχρησιμοποίησης μέσω κληρονομικότητας Μια κλάση με ένα υπερβολικά μεγάλο αριθμό παιδιών μπορεί να σημαίνει την κακή χρήση των subclass, ειδικά όταν η χρήση αυτών των παιδιών είναι ελάχιστη
Coupling between Object Classes 6 Αυτή η σύζευξη μπορεί να γίνει μέσω κλήση μεθόδων, field addresses, κληρονομικότητα, ορίσματα, τύποι επιστροφής, και exceptions Η υπερβολική σύζευξη κάνει το σύστημα πιο δύσκολο να συντηρηθεί και να επαναχρησιμοποιηθεί Αλλαγές σε μια κλάση μπορεί να επηρεάσει τις κλάσεις με τις οποίες έχει ψηλή σύζευξη και μετά είναι δύσκολο να απομονωθούν και να επαναχρησιμοποιηθούν αλλού Είναι πιο δύσκολο να ελέγξουμε στοιχεία ατομικά (unit testing) σε συστήματα με ψηλή σύζευξη
Response for a Class 7 Όταν το σύνολο responses μιας κλάσης περιλαμβάνει ένα μεγάλο αριθμό μεθόδων, είναι δύσκολο η κατανόηση, η αποσφαλμάτωση και ο έλεγχος της
Lack of Cohesion in Methods 8 Όταν αυτός ο δείκτης είναι ψηλός ίσως η κλάση να μπορεί να σπάσει σε ξεχωριστές κλάσεις και οι μέθοδοι που δεν μοιράζονται πεδία μπορούν να χωριστούν αναλόγως Ένας χαμηλός δείκτης δείχνουν ότι οι κλάσεις σχεδιάστηκαν σωστά με κατάλληλη χρήση encapsulation
Credits 9 www.spinelis.gr/sw/ckjm