Model Defect Metrics - SWC

Using programming language keywords for class names will ... Software Metrics, Prentice Hall, 1994. Number of ... R. Martin, "Agile Software Development:.
226KB Sizes 0 Downloads 73 Views
Model Defect Metrics Name AttrNameOvr

Description The class defines a property of the same name as an inherited attribute. During code generation, this may inadvertently hide the attribute of the parent class. Consider changing the name of the attribute in the child class.

CyclicInheritance

Class inherits from itself directly or indirectly. The inheritance graph must be a tree, SDMetrics no cycles are allowed. The class has two or more properties with identical names. Attribute names must be SDMetrics unique within the class. Class has duplicate operations. There are two or more operations with identical SDMetrics signatures (i.e., operation name and list of parameter types). Operation signatures must be unique within the class.

DupAttrNames DupOps

Keyword

Unnamed

Class name is a Java or C++ keyword. Using programming language keywords for class names will cause problems during code generation. Find another name for the class. Capitalizing the name will also help, see rule Not-Capitalized. Class, Attribute, Method, Paremeter has no name.

NoTypeAttr

The attribute has no specified type. Without a type, the attribute has no meaning in design, and code generation will not work. Specify a type for the attribute.

DupName NoTypeOp Detached model elements

The operation has two or more parameters with identical names. A method has perameters but they have no type. If a model is modeled in a modeling language but the elements are not displayed.

Uncoupled Classes

One class diagram contains at least two separate class diagrams, i.e., there is no connection between classes so that the model can be stored across multiple files.

White Spaces in Name

A name includes white spaces. This leads to an error during validation.

Reference A. Ramirez, P. Vanpeperstraete, A. Rueckert, K. Odutola, J. Bennett, L. Tolke, M. van der Wulp, "ArgoUML User Manual v0.16", 2004

A. Ramirez, P. Vanpeperstraete, A. Rueckert, K. Odutola, J. Bennett, L. Tolke, M. van der Wulp, "ArgoUML User Manual v0.16", 2004 A. Ramirez, P. Vanpeperstraete, A. Rueckert, K. Odutola, J. Bennett, L. Tolke, M. van der Wulp, "ArgoUML User Manual v0.16", 2004 D. Frankel, "Model Driven Architecture: Applying MDA to Enterprise Computing", Wiley, 2003. SDMetrics SDMetrics

Model Smell Metrics Name Long Method

Long Parameter List

Duplicated Attributes/ Methods/Classes Large Class

Inappropriate Intimacy

Number of Attributes

Description The longer the method the harder it is to see what it's doing.

Reference Fowler, Martin: Refactoring - Improving the design of Existing Code. AddisonWesley, 1999 Don't pass in everything the method needs; pass in enough so that the method can Fowler, Martin: Refactoring - Improving get to everything it needs. the design of Existing Code. AddisonWesley, 1999 Duplicated attributes/ methods/ classes are bad Fowler, Martin: Refactoring - Improving the design of Existing Code. AddisonWesley, 1999 A class that is trying to do too much can usually be identified by looking at how many Fowler, Martin: Refactoring - Improving instance variables it has. When a class has too many instance variables, duplicated the design of Existing Code. Addisoncode cannot be far behind. Wesley, 1999 Two classes are overly entertwined. Fowler, Martin: Refactoring - Improving the design of Existing Code. AddisonWesley, 1999 If the amount of attributes reaches a certain level M. Lorenz, J. Kidd, Object-oriented Software Metrics, Prentice Hall, 1994.

Number of Aggregations

The total number of aggregation relationships within a class diagram (each wholepart pair in an aggregation relationship)

Number of Dependencies

The total number of dependency relationships.

M. Genero, Non-Redundant Metrics for UML Class Diagram Structural Complexity, Advanced Information Systems Engineering, Vol. 2681, (2003) 127-142 Chidamber S.R., Kemerer C.F., A metrics suite for object oriented design, Software Engineering, IEEE Transactions, Vol. 20, (1994) 476-493

Number of Generalizations

Number of Generalizations Hierarchies

Distance of Inheritence Tree

The total number of generalization relationships within a class diagram (each parent- M. Genero, Non-Redundant Metrics for child pair in a generalization relationship) UML Class Diagram Structural Complexity, Advanced Information Systems Engineering, Vol. 2681, (2003) 127-142 The total number of generalization hierarchies within a class diagram. M. Genero, Non-Redundant Metrics for UML Class Diagram Structural Complexity, Advanced Information Systems Engineering, Vol. 2681, (2003) 127-142 The depth of the class in the inheritance hierarchy. This is calculated as the longest S. Chidamber, C. Kemerer, "A Metrics path from the class to the root of the inheritance tree. The DIT for a class that has no Suite for Object-Oriented Design", IEEE parents is 0. Classes with high DIT inherit from many classes and thus are more Transactions on Software Engineering, difficult to understand. Also, classes with high DIT may not be proper specializations 20 (6), 476-493, 1994. of all of their ancestor classes.

Getter/Setter Attributes with Variable Name Number of Interfaces

If there are methods with get/set/has prefix and the an existing variable name. They are generated dynamically! If a certain amount of interface implementation is handled by one class.

Number of external references

Count the numbers of models that reference this particular model.

SDMetrics R. Martin, "Agile Software Development: Principles, Patterns, and Practices", Prentice Hall, 2003.

Instability (Ease of change)

Number of references of a model to external classes / (number of references of a R. Martin, "Agile Software Development: model to external classes + number of references from other models to this model). Principles, Patterns, and Practices", A value close to 0 indicates a package that does not rely much on other packages, but Prentice Hall, 2003. is heavily relied upon by other packages. Such a package should be stable, because it is hard to change: changes to the package potentially have a large impact on the model ("ripple effects"). A value close to 1 indicates a package that mostly relies on other packages, but that itself is not much relied upon. Such a package can be unstable, because it is easy to change: changes to the package are not likely to have a large impact on the model.

God class Distance between classes Preceding verb for method name NotCapitalized

A class that has an association with nearly all other classes The distance between classes may indicate readability. Check attribute/method names if the first part is a verb, e.g. createForm

Capitalized

Attribute/method names should start with a lowercase letter.

Query

The operation name indicates a query, but it is not marked as a query. E.g. getName but method has no return type The class references a descendent class via associations, UML dependencies, attribute or parameter types. This is poor design. A class c should be oblivious of its descendent classes. The reference to the descendent class and the inheritance links back to class c effectively form a dependency cycle between these classes. Redesign this to eliminate the need for the reference to the descendent class.

DescendentRef

Class names should start with a capital letter.

Object Management Group, "UML 2.0 Superstructure Specification", OMG Adopted Formal Specification formal/0507-04, 2005. Object Management Group, "UML 2.0 Superstructure Specification", OMG Adopted Formal Specification formal/0507-04, 2005. SDMetrics Ramirez, P. Vanpeperstrae+A1:C38te, A. Rueckert, K. Odutola, J. Bennett, L. Tolke, M. van der Wulp, "ArgoUML User Manual v0.16", 2004.