improving the quality of emf models using metrics, smells, and … · 2017-11-01 · – occurrence...
TRANSCRIPT
Improving the quality of EMF models using metrics, smells, and refactorings
Gabriele Taentzer, Thorsten ArendtTutorial at ECMFA, July 2nd 2012, Lyngby, Denmark
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
Motivation: Model quality assurance
Improving the quality of EMF models
Problems
Risks
3
Model Refactorings
Model Smells
Model Metrics
Motivation: Model quality assurance
Improving the quality of EMF models
Problems
Risks
Model Refactorings
Model Smells
Model Metrics
Model Quality Assurance Process
4
A model quality assurance process
Improving the quality of EMF models5
A model quality assurance process
Improving the quality of EMF models
Specification of a project-specific model quality assurance process
6
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)
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
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
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
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
A model quality assurance process
Improving the quality of EMF models
Application of the specified process to concrete software models
12
Tool support in Eclipse
Improving the quality of EMF models
EMF MetricsEMF Metrics
13
Tool support in Eclipse
Improving the quality of EMF models
EMF MetricsEMF Smell
14
Tool support in Eclipse
Improving the quality of EMF models
EMF RefactorEMF Refactor
15
Topic of Tutorial
Improving the quality of EMF models
Problems
Risks
Model Refactorings
Model Smells
Model Metrics
Model Quality Assurance Process
16
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
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
Running example: UML class model
Improving the quality of EMF models19
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
EMF Metrics: configurationdialog
Improving the quality of EMF models21
EMF Metrics: result view
Improving the quality of EMF models22
Improving the quality of EMF models23
EMF Metrics: export dialog
Improving the quality of EMF models24
EMF Metrics: HTML export (bar diagram)
Improving the quality of EMF models25
EMF Metrics: PPT export (pie diagram)
Smell „Doer and Knower“ represents a lack of encapsulation.
Improving the quality of EMF models26
EMF Smell: configuration dialog
EMF Metrics: result view
Improving the quality of EMF models27
Improving the quality of EMF models28
EMF Smell: highlighting
Improving the quality of EMF models29
EMF Smell: PDF export (list)
Improving the quality of EMF models30
Relation: smell erasing refactorings
Improving the quality of EMF models31
Relation: smell causing refactorings
Improving the quality of EMF models32
Dialog: suggested refactorings
• Invocation on Smell Equal Attributes in Sibling Classes– Occurrence { Motorbike, power }
Improving the quality of EMF models33
Dialog: applicable refactorings
• Invocation on Smell Equal Attributes in Sibling Classes– Occurrence { Motorbike, power }
Improving the quality of EMF models34
EMF Refactor: parameter dialog
• Refactoring Pull Up Attribute– Context VehicleRentalCompany::Motorbike::power
Improving the quality of EMF models35
EMF Refactor: smell analysis
Improving the quality of EMF models36
EMF Refactor: result preview
Improving the quality of EMF models37
EMF Refactor: refactored model
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
Used UML specification diagrams
Improving the quality of EMF models39
Used UML specification diagrams
Improving the quality of EMF models40
Improving the quality of EMF models41
Specification of new metric NACP (Total number ofattributes in classes within the package): general data
Improving the quality of EMF models42
Specification of new metric NACP (Total number ofattributes in classes within the package): Java code
Improving the quality of EMF models43
Specification of new metric NOCP (Total number ofoperations in classes within the package): general data
Improving the quality of EMF models44
Specification of new metric NOCP (Total number ofoperations in classes within the package): OCL expr.
Improving the quality of EMF models45
Specification of new metric KFP (Knowing Factor): general data
Improving the quality of EMF models46
Specification of new metric KFP (Knowing Factor): metric data
Improving the quality of EMF models47
Specification of new smell ‘Too Many Knowers in Package’: general data
Improving the quality of EMF models48
Specification of new smell ‘Too Many Knowers in Package’: metric data
Used UML specification diagrams (cont.)
Improving the quality of EMF models49
Used UML specification diagrams (cont.)
Improving the quality of EMF models50
Used UML specification diagrams (cont.)
Improving the quality of EMF models51
Improving the quality of EMF models52
Specification of new smell ‘Unused Interface’: general data
Improving the quality of EMF models53
Specification of new smell ‘Unused Interface’: Henshin pattern rule specification
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
Improving the quality of EMF models55
Specification of new refactoring ‘Remove Unused Interface’: general data
Improving the quality of EMF models56
Specification of new refactoring ‘Remove Unused Interface’: Henshin data
Improving the quality of EMF models57
Specification of new refactoring ‘Remove Unused Interface’: Henshin’s initial check
Improving the quality of EMF models58
Specification of new refactoring ‘Remove Unused Interface’: Henshin’s model change
Improving the quality of EMF models59
Specification of new refactoring ‘Remove Unused Interfaces from Package’: CoMReL data
Improving the quality of EMF models60
Specification of new refactoring ‘Remove Unused Interfaces from Package’: CoMReL specification
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
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
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
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
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
Implemented model quality assurance techniques
Improving the quality of EMF models66
Ecore models UML2EMF models
Metrics 17 106
Smells 10 30
Refactorings 22 30
Tool environment for model quality assurance
• Download
– http://www.eclipse.org/modeling/emft/refactor/• Downloads• Specials
Improving the quality of EMF models67