27
By: Eng. Mohamed Awad Elshaarawy Supervisors: Prof. Dr. Ismail Taha, Dr. Haitham S.Hamza Date: 8 th Jul, 2013 Towards a Unified Framework for Measuring the Properties of Class Diagrams Augmented with OCL

By: Eng. Mohamed Awad Elshaarawy Supervisors: Prof. Dr. Ismail Taha, Dr. Haitham S.Hamza Date: 8 th Jul, 2013 Towards a Unified Framework for Measuring

Embed Size (px)

Citation preview

By: Eng. Mohamed Awad Elshaarawy

Supervisors: Prof. Dr. Ismail Taha, Dr. Haitham

S.Hamza

Date: 8th Jul, 2013

Towards a Unified Framework for Measuring

the Properties of Class Diagrams Augmented with

OCL

2

• Introduction

• Related Work

• Motivation

• Thesis Contribution

• Proposed Model

• Controlled Experiments and

Results

• Conclusion & Future Work

3

Class DiagramIn software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among the classes

Introduction

4

OCL Object Constraint Language

1. In order to write clear, understandable and standardized constraints, OCL have been developed

2. OCL is a formal, modeling, typed and pure expression language used to specify (invariants, pre-and post conditions on operations and methods and as navigation language

3. Formal language for the definition of constraints and queries on UML models4. Declarative to add precise semantics

Introduction

context CustomerCardinvariant correctDates: validFrom.isBefore(goodThru)isBefore(Date):Boolean is a Date operation.context CustomerCardinvariant: owner.age() >= 18context CustomerCardinvariant printedName:printedName = owner.title.concat(‘ ‘).concat(owner.name)context Membership

1

2

3

4

5

Class Diagram Metrics Brief

Related Work

Briand

Chidamber & Kemerer

1

Marchesi

Lorenz & Kidd’s

Li & Henry

2

Brito

4

5

3

6

Briand et al provided metrics which could distinguish the relationship between classes’ different type of interactions, and the locus of impact of the interaction

Chidamber and Kemerer proposed six metrics for the measurement of OO systems. Only three of the six CK metrics are available for a UML class diagram

Li and Henry defined metrics that tend to measure different internal attributes such as coupling, complexity and size

Brito proposed MOOD metrics to measure the use of OO design mechanisms such as inheritance, information hiding, and polymorphism

Lorenz and Kidd’s proposed Class size metrics, Class inheritance metrics and Class’ internals metrics

Marchesi Proposed three categories of metrics: those related to single classes, those related to packages and those related to the system as a whole

6

Class Diagram Metrics Brief

Related Work

Zhou

Harrison7

Bansiya & Davis

8

Genero

10

9

Zhou only used one indicator, namely entropy distance based structure complexity metric, to evaluate the complexity of class diagrams

Harrison et al. defined metric to measure the inter-class coupling

Bansiya and Davis defined metrics for assessing design properties such as encapsulation, coupling, cohesion, composition and inheritanceGenero defined metrics to measure class diagram complexity, due to the use of different kinds of relationships, such as associations, generalizations, aggregations and dependencies, in relation with their impact on external quality attributes such as class diagram maintainability

Reynosa, Genero &Piattini

11

Cabot & Teniente

12

Reynosa, Genero &Piattini defined a metric suite for measuring structural properties of OCL expressions

Cabot and Teniente presented a new metric to measure the complexity of OCL expressions

7

OCL Metrics Brief

Related Work

Reynosa, Genero &Piattini

1

Cabot & Teniente

2

Reynosa, Genero &Piattini defined a metric suite for measuring structural properties of OCL expressions

Cabot and Teniente presented a new metric to measure the complexity of OCL expressions

8

Motivation & Objectives

Lack of an integrated metrics suites that consider class diagrams with its OCL expressions as a one chunk.

An integrated framework has been presented to assess the structural properties of the class diagram made using the unified modeling language (UML) with considering the added complexity involved when a class diagram is augmented with expressions written in (OCL)

Answering the question of whether using OCL is in the benefit and not only the efficiency of the work but also the effectiveness‘ of it.

A controlled experiment’s results analysis has been provided answering this common question.

propose a unified framework contains a set of “Integrated” metrics, a set of new class diagram metrics, a set of new OCL metrics in additions to the well-known class diagram and OCL metrics that have been selected for their extensively use, relevant scope and validity

presents the results of a controlled experiment that investigates the impact of using OCL on class diagram comprehension and maintainability

provide the theoretical and empirical validation for the proposed metrics

Objectives

1

2

3

Motivation

1

2

9

Proposed Model Brief

•The structural properties will be measured are: size, length and coupling. And, the scopes of measures are: class diagram, OCL expressions and class diagram augmented with OCL (integrated metrics)

•So, the proposed metrics structured as follows: three metrics suites size measurement metrics suite, length measurement metrics suite and coupling measurement metrics suite). Each suite consists of class diagram scope, OCL expressions scope and integrated class diagram _OCL metrics

10

Size Measurement Metric Suite

Class Diagram Size Scope Metrics

The selected well known (existing literature) metrics are : CdNC(Class diagram number of classes), CdNM (Class diagram number of methods), CdNAss (Class diagram number of association relationships) for uni directional and bi directional association, CdNAgg ( Class diagram no. of aggregation relationships), CdNDep (Class diagram number of dependency relationships), CdNGen (Class diagram number of generalization relationships), CdNGenH (Class diagram number of generalization hierarchies ), CdNAggH (Class diagram number of aggregation hierarchies)

The proposed metrics are: CdNA (Class diagram number of attributes), CdNR (Class diagram no. of relations) it can be calculated by: CdNR =CdNAss+ CdNAgg+ CdNDep+ CdNGen+ CdNGenH+ CdNAggH

11

OcNoBj (the no. of objects in Bexp where Bexp is the bag of objects accessed during the evaluation of an expression),

OcWNM (OCL expressions Weighted No. of Messages),

OcWNN (OCL expressions Weighted No. of Navigations)

OcNL (OCL expressionsNo. of Lines),OcNC (OCL expressions No. of constraints),OcNI (OCL expressions No. of Invariants),OcNO (OCL expressions No. of Operations) Including operations Boolean type, operations on integer and real types, operations on string types, operations on collection types and query operation, OcNCond (OCL expressions No. of pre and post Conditions), OcNV (OCL expressions No. of Variables defined through <<Definition>> constraints included number of variables defined by Let expressions in an expression),

OcNaA (OCL expressions No. of accessed class diagram attributes),OcNaM (OCL expressions No. of accessed class diagram Methods), OcNaR (OCL expressions No. of accessed class diagram Relations),

OcNaC (OCL expressions No. of accessed classes)

Size Measurement Metric Suite

OCL Expressions Size Scope Metrics

12

Classes' Density: The ratio of (total no. of accessed classes in OCL expressions /total no. of classes within class diagram= OcNaC/CdNC) this represents the extra complexity added to CdNC due to using OCL

Attributes' Density: The ratio of (total no. of accessed attributes In OCL expressions /total no. of attributes within class diagram= OcNaA/CdNA) this represents the extra complexity added to CdNA due to using OCL

Methods’ Density: The ratio of (total no. of accessed method. In OCL expressions /total no. of methods within class diagram= OcNaM/CdNM) this represent the extra complexity added to CdNM (no. of methods) due to using OCL

Relations' Density: The ratio of (total no. of accessed relations In OCL expressions /total no. of relations within class diagram=OcNaR/CdNR) this represents the extra complexity added to CdNR due to using OCL

Size Measurement Metric Suite

Integrated Size Scope Metrics

13

Following the property based framework of Briand, it has been assured that all of the size metrics suite fulfill all of the following axioms that characterize size metrics:

PropertySize.1 (Non-negativity): This property is directly proven because it is impossible to obtain a negative value for all of the size metrics suites

PropertySize.2 (Null value): Any system from the above described three systems have no elements will lead to its related metrics =0

PropertySize.3 (Module Additivity): This property is directly proven because the size of a system is equal to the sum of the sizes of its modules

Size Measurement Metric Suite

Theoretical validation

14

These metrics were grouped into: class diagram length scope metrics, OCL expressions length scope metrics and class diagram augmented with OCL length scope metrics.

Class Diagram Length Scope Metrics:

CdMaxDIT (The maximum between the Depth of Inheritance DIT values obtained for each class of the class diagram, The DIT value for a class within a generalization hierarchy is the length of the longest path from the class to the root of the hierarchy) ,CdMaxHAgg (The maximum between the Hierarchical Aggregation (HAgg) values obtained for each class of the class diagram ,The HAgg value for a class within an aggregation hierarchy is the length of the longest path from the class to the leaves)Units.

OCL Expressions Length Scope Metrics:

OcDN : Depth of Navigations (DN) is the maximum depth of the navigation tree

Max Depth: the added length to the longest path from the class to others related classes in the class diagram due to navigation tree build after using OCL

Length Measurement Metric Suite

Class Diagram & OCL Length Scope Metrics

15

Following the property based framework of Briand, it has been assured that all of the length metrics suite fulfill all of the following axioms that characterize length metrics:

•PropertyLength.1 (Nonnegativity) and Null Value are straightforwardly satisfied, the depth of a tree can never be negative, and an expression without navigation has an empty tree.

•PropertyLength.2 (Nonincreasing monotonocity) for connected components: If we add relationships between elements of a tree (classes or interfaces) the depth of the tree does not vary.

•PropertyLength.3 (Nondecreasing monotonocity) for non- connected components: Adding a relationship to two unconnected components (two trees) makes them connected, and its length is not less than the length of the two unconnected components.

•PropertyLength.4 (Disjoint modules): The depth of a tree is given by the component that has more levels from the root to the leaves.

Length Measurement Metric Suite

Theoretical Validation

16

These metrics were grouped into: class diagram coupling scope metrics, OCL expressions coupling scope metrics and class diagram augmented with OCL coupling scope metrics. (Integrated metrics)

Class Diagram Coupling Scope Metrics:

CdNPCAIC (Number of coupling relationship to Parent classes if there is a Class-attribute interaction between classes of Import coupling type) , CdNOCAIC (Number of coupling relationship to other classes if there is a Class-attribute interaction between classes of Import coupling type ), CdNDCAEC (Number of coupling relationship to descendant classes if there is a Class-attribute interaction between classes of Export coupling type), CdNOCAEC (Number of coupling relationship to other classes if there is a Class-attribute interaction between classes of Export coupling type), CdNPCMIC (Number of coupling relationship to parent classes if there is a Class-Method interaction between classes of Import coupling type ),CdNOCMIC (Number of coupling relationship to other classes if there is a Class-Method interaction between classes of Import coupling type )

CdNDCMEC (Number of coupling relationship to descendant classes if there is a Class-Method interaction between classes of Export coupling type,CdNOCMEC (Number of coupling relationship to other classes if there is a Class-Method interaction between classes of Export coupling type)

Coupling Measurement Metric Suite

Class Diagram Coupling Scope Metrics

17

OcNPT (The OCL expressions Number of Parameters whose types are classes defined in the class diagram),

OcNAN (The OCL expressions Number of attributes referred through navigations in an expression,

OcWNM (OCL expressions Weighted No. of Messages),

OcWNO (The OCL expressions Weighted Number of referred Operations through navigations)

Coupling Measurement Metric Suite

OCL Expressions Coupling Scope Metrics

18

•Classes Fan-In: The extra number of classes due to using OCL expressions that use a specific class above the classes that originally use this specific class in the class diagram•Methods Fan-In: The extra number of Methods due to using OCL expressions that use a specific method in OCL operations above the methods that originally use this specific method in the class diagram•Messages Fan-In: The extra number of messages due to using OCL expressions that use a specific message above the messages that originally use this specific message in the class diagram•Classes Fan-Out: The extra number of classes due to using OCL expressions that a specific class calls above the number of classes that originally have been called by this class in the class diagram•Methods Fan-Out: The extra number of methods due to using OCL expressions that a specific method calls above the number of methods that originally have been called by this method in the class diagram•Attributes Fan-Out: The extra number of Attributes due to using OCL expressions (let and call expressions) that a specific method calls above the number of attributes that originally have been called by this Method in the class diagram

Coupling Measurement Metric Suite

Integrated Coupling Scope Metrics

19

Following the property based framework of Briand, it has been assured that all of the coupling metrics suite fulfill all of the following axioms that characterize coupling metrics:

•PropertyCoupling.1 (Non-negativity): Is directly proven, and it is impossible to obtain a negative value for all of stated metrics

•PropertyCoupling.2 (Monotonicity): Is directly verified, adding import interactions - in this case, DU-interactions (interaction from Data declaration to data Used in an OCL expression)

•PropertyCoupling.3 (Merging Modules): This property can be expressed for our context in the following way: “the sum of the import coupling of two modules is no less than the coupling of the module which is composed of the data used of the two modules”. The value of metrics for an expression which consists of the union of two original expressions, is equal to the metrics of each expression merged when the sets of classes, methods, attributes and messages referred to in each original expression are disjointed, otherwise is less than metrics of each merged expression

Coupling Measurement Metric Suite

Theoretical Validation

Experiments PlanningDefinition

The purpose of this experiment is to analyze UML class diagrams with its OCL expressions proposed framework metrics and to evaluate the metrics results with the subjects’ ratings results indicating the impact of using OCL, combined with UML class diagrams on the understandability and maintainability degree.

Context & Material Selection

The context of the experiment is a group related to the area of Software Engineering in different seniority levels. They were grouped into 4 groups (8 subjects per group) and each subject worked individually on each of the two systems, using class diagram+OCL in one case and only class diagram in the other.

Two comparable, in terms of complexity and size, class diagrams with their OCL expressions representing (Royal& Loyal system and Hotel management system) are used.

20

Controlled Experiment

• The impact of using OCL will be assessed on two dependent variables: Understandability (U) and Maintainability (M) were measured according to the subjects’ ratings (of the experiment’s designed questionnaires) targets the system logic(U), and the ability of subjects to correctly specify the affected system elements due to changes in requirements(M). The other dependent variable is Maintenance time which is comprises the time to comprehend the class diagram, analyze the required changes and to implement them.

• The null hypothesis (H0): There is no significant correlation between the framework metrics and the above variables

• The alternative hypothesis (Ha): There is a significant correlation between the framework metrics and the above variables

21

Controlled Experiment

Hypothesis Formulation

Instrumentation: •Besides the class diagrams with its OCL expressions separate documents, other forms were used like a survey questionnaire was distributed to obtain information about the subjects’ background. After the completion of both Understandability and Maintenance tasks, forms were distributed that contains specific questions about the system. Maintenance questions address the Maintainability variable •All of the questions were covered different parts of the system, feasible to answer but not trivial and could be answered with or without OCL. •In addition, another after-lab questionnaire was distributed with questions addresses the selected variables.Those questions were answered on a Likert scale from 1 (Strongly agree) to 5 (Strongly disagree)

Execution and Data Validation: •The operations were done successfully and all the data have been collected including subjects’ answers obtained from the responses of the experiment and the metrics value

22

Controlled Experiment

23

Cla

sses

’ D

ensi

ty

Att

ribu

tes’

Den

sity

Met

hods

’ D

ensi

ty

Rel

atio

ns’

Den

sity

Ext

ra l

engt

h

Cla

sses

Fan

-In

Met

hods

Fan

-In

Mes

sage

s F

an-I

n

Cla

sses

Fan

-Out

Met

hods

Fan

-Out

Mes

sage

s F

an-O

ut

Understability 0.892 0.859 0.789 0.912 0.589 0.677 0.718 0.857 0.683 0.881 0.789

Maintainability 0.896 0.909 0.812 0.926 0.588 0.759 0.673 0.891 0.693 0.848 0.788

Controlled Experiment

Spearman's correlation between the metrics and Understandability and Maintainability

we can conclude that there is a significant correlation between the proposed integrated class diagram & OCL structural complexity metrics and subject’s rating

24

Controlled Experiment II

Cla

sses

’ D

ensi

ty

Att

ribu

tes’

Den

sity

Met

hods

’ D

ensi

ty

Rel

atio

ns’

Den

sity

Ext

ra le

ngth

Cla

sses

Fan

-In

Met

hods

Fan

-In

Mes

sage

s F

an-I

n

Cla

sses

Fan

-Out

Met

hods

Fan

-Out

Mes

sage

s F

an-O

ut

maintenance time

0.941 p=0

0.803 p=0.009

0.795 p=0.01

0.671 p=0.006

0.667 p=0.049

0.721 p=0.272

0.728 p=0.04

0.759 p=0.018

0.719 p=0.029

0.840 p=0.005

0.669 p=0.04

Null hypothesis, H0: There is no significant correlation between structural complexity metrics and maintenance timeAlternative hypothesis, H1 : There is a significant correlation between structural complexity metrics and maintenance timeBy calculating the mean of the maintenance time

|It’s concluded that there is a significant correlation between all the metrics and the

maintenance time

25

This thesis shows how we defined a metric suite for measuring the overall Structural Properties of a class diagram augmented with OCL

Also, it shows the best way from our point of view to measure the Structural Properties of a class diagram and the OCL expressions individually

We validated our framework theoretically by using the property-based framework of Briand et al. and classified it to size, length and interaction-based metrics for coupling

A controlled experiment was done to validate the proposed framework empirically and shows that there are correlations between the metrics and their tested variables. And also shows that OCL, as a constraint language complementary to UML class diagrams, is useful in helping understand system models facilitate change and understanding

Obviously that the benefits of using OCL may only be observed if subjects have sufficient training and/or obtained sufficient experience in UML class diagrams and OCL

The extension of the proposed work to cover other UML diagrams is very important to make a unified framework for measuring the overall structural properties of UML diagrams which augmented with OCL

Conclusion

26

The extension of the proposed work to cover other UML diagrams is very important to make a unified framework for measuring the overall

structural properties of UML diagrams which augmented with OCL

Future Work

Q&A