improving the quality of emf models using metrics, …...improving the quality of emf models using...

67
Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at ECMFA, July 2 nd 2012, Lyngby, Denmark

Upload: others

Post on 23-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models using metrics, smells, and refactorings

Gabriele Taentzer, Thorsten ArendtTutorial at ECMFA, July 2nd 2012, Lyngby, Denmark

Page 2: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Outline

• Introduction

• Running Example

• Demo: Application of Model Quality Assurance Techniques

• Demo: Specification of Model Quality Assurance Techniques

• Conclusion

Improving the quality of EMF models2

Page 3: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Motivation: Model quality assurance

Improving the quality of EMF models

Problems

Risks

3

Model Refactorings

Model Smells

Model Metrics

Page 4: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Motivation: Model quality assurance

Improving the quality of EMF models

Problems

Risks

Model Refactorings

Model Smells

Model Metrics

Model Quality Assurance Process

4

Page 5: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process

Improving the quality of EMF models5

Page 6: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process

Improving the quality of EMF models

Specification of a project-specific model quality assurance process

6

Page 7: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process: 6C Goals 1

Improving the quality of EMF models

Specification of a project-specific model quality assurance process

7

– Correctness– Completeness– Changeability

– Comprehensibility– Confinement– Consistency

1 P. Mohagheghi, V. Dehlen, T. Neple: Definitions and approaches to model quality in model-based software development - A review of literature. Information & Software Technology 51 (12): 1646-1669 (2009)

Page 8: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process: Smells

Improving the quality of EMF models

Specification of a project-specific model quality assurance process

8

• Example: Are there equally named classes in different packages?

– Smell: Multiple definitions of classes with equal names

Changeability Comprehensibility

Page 9: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process: Smells

Improving the quality of EMF models

Specification of a project-specific model quality assurance process

9

• Example: Are there abstract classes without any concrete subclasses?

– Smell: No concrete subclass

Completeness Comprehensibility

Page 10: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process: Refactoring

Improving the quality of EMF models

Specification of a project-specific model quality assurance process

10

• Smell: Multiple definitions of classes with equal names– Refactoring: Rename Class

Page 11: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process: Refactoring

Improving the quality of EMF models

Specification of a project-specific model quality assurance process

11

• Smell: Multiple definitions of classes with equal names– Refactoring: Rename Class

• Smell: No concrete subclass– Refactoring: Insert Concrete Subclass

Page 12: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process

Improving the quality of EMF models

Application of the specified process to concrete software models

12

Page 13: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool support in Eclipse

Improving the quality of EMF models

EMF MetricsEMF Metrics

13

Page 14: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool support in Eclipse

Improving the quality of EMF models

EMF MetricsEMF Smell

14

Page 15: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool support in Eclipse

Improving the quality of EMF models

EMF RefactorEMF Refactor

15

Page 16: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Topic of Tutorial

Improving the quality of EMF models

Problems

Risks

Model Refactorings

Model Smells

Model Metrics

Model Quality Assurance Process

16

Page 17: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Outline

• Introduction

• Running Example

• Demo: Application of Model Quality Assurance Techniques

• Demo: Specification of Model Quality Assurance Techniques

• Conclusion

Improving the quality of EMF models17

Page 18: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Example: Vehicle Rental Company

• Project– Development of a web

application for renting vehicles• Semantic domain

– Company with • Vehicles• Customers• Services

• Technical domain– Web application

• Modeling purpose– Modeling of the semantic domain

Improving the quality of EMF models18

Page 19: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Running example: UML class model

Improving the quality of EMF models19

Page 20: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Outline

• Introduction

• Running Example

• Demo: Application of Model Quality Assurance Techniques

• Coffee Break

• Demo: Specification of Model Quality Assurance Techniques

• Conclusion

Improving the quality of EMF models20

Page 21: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

EMF Metrics: configurationdialog

Improving the quality of EMF models21

Page 22: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

EMF Metrics: result view

Improving the quality of EMF models22

Page 23: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models23

EMF Metrics: export dialog

Page 24: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models24

EMF Metrics: HTML export (bar diagram)

Page 25: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models25

EMF Metrics: PPT export (pie diagram)

Smell „Doer and Knower“ represents a lack of encapsulation.

Page 26: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models26

EMF Smell: configuration dialog

Page 27: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

EMF Metrics: result view

Improving the quality of EMF models27

Page 28: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models28

EMF Smell: highlighting

Page 29: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models29

EMF Smell: PDF export (list)

Page 30: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models30

Relation: smell erasing refactorings

Page 31: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models31

Relation: smell causing refactorings

Page 32: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models32

Dialog: suggested refactorings

• Invocation on Smell Equal Attributes in Sibling Classes– Occurrence { Motorbike, power }

Page 33: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models33

Dialog: applicable refactorings

• Invocation on Smell Equal Attributes in Sibling Classes– Occurrence { Motorbike, power }

Page 34: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models34

EMF Refactor: parameter dialog

• Refactoring Pull Up Attribute– Context VehicleRentalCompany::Motorbike::power

Page 35: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models35

EMF Refactor: smell analysis

Page 36: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models36

EMF Refactor: result preview

Page 37: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models37

EMF Refactor: refactored model

Page 38: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Outline

• Introduction

• Running Example

• Demo: Application of Model Quality Assurance Techniques

• Coffee Break

• Demo: Specification of Model Quality Assurance Techniques

• Conclusion

Improving the quality of EMF models38

Page 39: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Used UML specification diagrams

Improving the quality of EMF models39

Page 40: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Used UML specification diagrams

Improving the quality of EMF models40

Page 41: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models41

Specification of new metric NACP (Total number ofattributes in classes within the package): general data

Page 42: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models42

Specification of new metric NACP (Total number ofattributes in classes within the package): Java code

Page 43: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models43

Specification of new metric NOCP (Total number ofoperations in classes within the package): general data

Page 44: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models44

Specification of new metric NOCP (Total number ofoperations in classes within the package): OCL expr.

Page 45: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models45

Specification of new metric KFP (Knowing Factor): general data

Page 46: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models46

Specification of new metric KFP (Knowing Factor): metric data

Page 47: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models47

Specification of new smell ‘Too Many Knowers in Package’: general data

Page 48: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models48

Specification of new smell ‘Too Many Knowers in Package’: metric data

Page 49: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Used UML specification diagrams (cont.)

Improving the quality of EMF models49

Page 50: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Used UML specification diagrams (cont.)

Improving the quality of EMF models50

Page 51: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Used UML specification diagrams (cont.)

Improving the quality of EMF models51

Page 52: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models52

Specification of new smell ‘Unused Interface’: general data

Page 53: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models53

Specification of new smell ‘Unused Interface’: Henshin pattern rule specification

Page 54: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Refactoring application workflow

Integration of Smells and Refactorings within EMF

Initial Precondition Check

Final Precondition Check

Model Change

Refactoring Invocation

Parameter Input

Error Message

Model Change Preview

54

Page 55: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models55

Specification of new refactoring ‘Remove Unused Interface’: general data

Page 56: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models56

Specification of new refactoring ‘Remove Unused Interface’: Henshin data

Page 57: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models57

Specification of new refactoring ‘Remove Unused Interface’: Henshin’s initial check

Page 58: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models58

Specification of new refactoring ‘Remove Unused Interface’: Henshin’s model change

Page 59: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models59

Specification of new refactoring ‘Remove Unused Interfaces from Package’: CoMReL data

Page 60: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Improving the quality of EMF models60

Specification of new refactoring ‘Remove Unused Interfaces from Package’: CoMReL specification

Page 61: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Outline

• Introduction

• Running Example

• Demo: Application of Model Quality Assurance Techniques

• Coffee Break

• Demo: Specification of Model Quality Assurance Techniques

• Conclusion

Improving the quality of EMF models61

Page 62: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

A model quality assurance process

Improving the quality of EMF models62

Specification of a project-specific model quality assurance process

Application of the specified process to concrete software models

Page 63: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool environment for model quality assurance

Improving the quality of EMF models

Problems

Risks

Model Refactorings

Model Smells

Model Metrics

Model Quality Assurance Process

63

Page 64: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool environment for model quality assurance

• Highly integrated

– Specific tools use each other• Metric-based model smells• Refactoring invocation from within model smell results view• Model smell analysis during refactoring application

– Each tool can be used directly on the model within a certain EMF-based modeling environment

• EMF instance editor• Unified Modeling Language (UML)

– Eclipse Plugin Papyrus– IBM Rational Software Architect

Improving the quality of EMF models64

Page 65: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool environment for model quality assurance

• Flexible specification mechanisms

– Usage of existing quality assurance techniques• Combination of existing model metrics• Metric-based model smells• Composite model refactorings

– Usage of concrete specification languages• Java• OCL• EMF model transformation language Henshin• … further languages can be integrated by new adapters

Improving the quality of EMF models65

Page 66: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Implemented model quality assurance techniques

Improving the quality of EMF models66

Ecore models UML2EMF models

Metrics 17 106

Smells 10 30

Refactorings 22 30

Page 67: Improving the quality of EMF models using metrics, …...Improving the quality of EMF models using metrics, smells, and refactorings Gabriele Taentzer, Thorsten Arendt Tutorial at

Tool environment for model quality assurance

• Download

– http://www.eclipse.org/modeling/emft/refactor/• Downloads• Specials

Improving the quality of EMF models67