SlideShare uma empresa Scribd logo
1 de 7
Baixar para ler offline
USAGE CONTRACTS* 
KIM MENS 
UNIVERSITÉ CATHOLIQUE DE LOUVAIN (UCL) 
JOINT WORK WITH 
ANGELA LOZANO 
ANDY KELLENS 
DAGSTUHL SEMINAR – “THE FUTURE OF REFACTORING” 
LIGHTNING TALK – 21.05.2014 
* SLIDES LARGELY BASED ON AN EARLIER PRESENTATION MADE BY ANGELA LOZANO
USAGE CONTRACTS 
/** 
* Deactivates the tool. This method is called whenever the user switches to another tool 
* Use this method to do some clean-up when the tool is switched. 
* Subclassers should always call super.deactivate. 
* An inactive tool should never be deactivated. 
*/ 
public void deactivate() { 
if (isActive()) { 
if (getActiveView() != null) { 
getActiveView().setCursor(new AWTCursor(java.awt.Cursor.DEFAULT_CURSOR)); 
} 
getEventDispatcher().fireToolDeactivatedEvent(); 
} 
} 
• We want a tool that allows encoding such regularities and offering immediate 
feedback on violations of such structural source-code regularities 
• The tool should be proactive (violations reported ‘on the fly’ during coding) 
• The tool should be “developer-friendly” (like unit testing but for usage expectations) 
• desired regularities expressed in the same programming language 
• tight integration with the integrated development environment 
• not coercive
METAPHOR 
Provider 
uses 
Consumer 
Usage 
Contract 
describes 
expectations 
of 
should 
comply 
with
EXAMPLE 
copyFrom: anEntity within: aVisitor 
inherits 
from 
copyFrom: anEntity within: aVisitor 
super copyFrom: anEntity within: aVisitor 
... 
All overriders of 
copyFrom:within: 
should start with a 
super call 
describes 
expectations 
of 
should 
comply 
with
EXAMPLE 
copyFrom: anEntity within: aVisitor 
inherits 
from 
copyFrom: anEntity within: aVisitor 
super copyFrom: anEntity within: aVisitor 
... 
All overriders of 
copyFrom:within: 
should start with a 
super call 
describes 
expectations 
of 
should 
comply 
with 
EContract 
classesInFAMIXSourcedEntityHierarchy 
<liableHierarchy:#FAMIXSourcedEntity> 
FAMIXSourcedEntityContract 
classesInFAMIXSourcedEntityHierarchy 
copyFromWithinWithCorrectSuperCall 
Liable 
entity 
copyFromWithinWithCorrectSuperCall 
<selector:#copyFrom:within:> 
contract 
require: 
condition beginsWith: 
(condition doesSuperSend: #copyFrom:within:) 
if: (condition isOverridden) 
Contract 
term 
Contract 
conditions
UCONTRACTS : THE LANGUAGE 
EContract 
Liable classes 
•liableClass: regExp / exceptClass: regExp 
•liableHierarchy: className / exceptHierarchy: className 
•liablePackage: regExp / exceptPackage: regExp 
classesInFAMIXSourcedEntityHierarchy 
<liableHierarchy:#FAMIXSourcedEntity> 
FAMIXSourcedEntityContract 
classesInFAMIXSourcedEntityHierarchy 
copyFromWithinWithCorrectSuperCall 
Liable 
entity 
copyFromWithinWithCorrectSuperCall 
<selector:#copyFrom:within:> 
contract 
require: 
condition beginsWith: 
(condition doesSuperSend: #copyFrom:within:) 
if: (condition isOverridden) 
Contract 
term 
Contract 
conditions 
Liable methods 
•selector: regExp / exceptSelector: regExp 
•protocol: regExp / exceptProtocol: regExp 
•/ exceptClass: className selector: selector 
Contract terms 
•require: condition 
•suggest: condition 
•require: condition if: anotherCondition 
•suggest: condition if: anotherCondition 
Contract conditions 
•assigns: regExp 
•calls: regExp 
•references: regExp 
•returns: expression 
•doesSuperSend: regExp 
•doesSelfSend: regExp 
•inProtocol: regExp 
•isOverridden: selector 
•isOverridden 
•isImplemented: selector 
•custom: visitor 
! 
•and: cond1 with: cond2 
•or: cond1 with: cond2 
•not: cond 
! 
•beginsWith: cond 
•endsWith: cond 
•does: cond1 after: cond2 
•does: cond1 before: cond2
UCONTRACTS : THE TOOL

Mais conteúdo relacionado

Semelhante a Usage contracts in a nutshell

Cold fusion best practice
Cold fusion best practiceCold fusion best practice
Cold fusion best practice
isummation
 
Delegates and Events in Dot net technology
Delegates and Events  in Dot net technologyDelegates and Events  in Dot net technology
Delegates and Events in Dot net technology
ranjana dalwani
 

Semelhante a Usage contracts in a nutshell (20)

Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)
 
Fragility in evolving software
Fragility in evolving softwareFragility in evolving software
Fragility in evolving software
 
Important React Hooks
Important React HooksImportant React Hooks
Important React Hooks
 
Cold fusion best practice
Cold fusion best practiceCold fusion best practice
Cold fusion best practice
 
Virtual events in C#: something went wrong
Virtual events in C#: something went wrongVirtual events in C#: something went wrong
Virtual events in C#: something went wrong
 
Delegates and Events in Dot net technology
Delegates and Events  in Dot net technologyDelegates and Events  in Dot net technology
Delegates and Events in Dot net technology
 
Behavioral pattern 4
Behavioral pattern 4Behavioral pattern 4
Behavioral pattern 4
 
Environment Variables in Angular
Environment Variables in AngularEnvironment Variables in Angular
Environment Variables in Angular
 
exception%20handlingcpp.pptx
exception%20handlingcpp.pptxexception%20handlingcpp.pptx
exception%20handlingcpp.pptx
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
Fraglight: Shedding Light on Broken Pointcuts Using Structural Commonality
Fraglight: Shedding Light on Broken Pointcuts Using Structural CommonalityFraglight: Shedding Light on Broken Pointcuts Using Structural Commonality
Fraglight: Shedding Light on Broken Pointcuts Using Structural Commonality
 
React Hooks
React HooksReact Hooks
React Hooks
 
UContracts a DSL to document and validate structural requirements of frameworks
UContracts a DSL to document and validate structural requirements of frameworksUContracts a DSL to document and validate structural requirements of frameworks
UContracts a DSL to document and validate structural requirements of frameworks
 
EventHandling.pptx
EventHandling.pptxEventHandling.pptx
EventHandling.pptx
 
The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on Android
 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - Gameplay
 
Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...
Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...
Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...
 
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
 
Ext oo
Ext ooExt oo
Ext oo
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 

Mais de kim.mens

Mais de kim.mens (20)

Software Maintenance and Evolution
Software Maintenance and EvolutionSoftware Maintenance and Evolution
Software Maintenance and Evolution
 
Context-Oriented Programming
Context-Oriented ProgrammingContext-Oriented Programming
Context-Oriented Programming
 
Software Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented ProgrammingSoftware Reuse and Object-Oriented Programming
Software Reuse and Object-Oriented Programming
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Domain Modelling
Domain ModellingDomain Modelling
Domain Modelling
 
Object-Oriented Application Frameworks
Object-Oriented Application FrameworksObject-Oriented Application Frameworks
Object-Oriented Application Frameworks
 
Towards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation FrameworkTowards a Context-Oriented Software Implementation Framework
Towards a Context-Oriented Software Implementation Framework
 
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty ApproachesTowards a Taxonomy of Context-Aware Software Variabilty Approaches
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
 
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software EngineeringBreaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
 
Context-oriented programming
Context-oriented programmingContext-oriented programming
Context-oriented programming
 
Basics of reflection
Basics of reflectionBasics of reflection
Basics of reflection
 
Advanced Reflection in Java
Advanced Reflection in JavaAdvanced Reflection in Java
Advanced Reflection in Java
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
Reflection in Ruby
Reflection in RubyReflection in Ruby
Reflection in Ruby
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Introduction to Smalltalk
Introduction to SmalltalkIntroduction to Smalltalk
Introduction to Smalltalk
 
A gentle introduction to reflection
A gentle introduction to reflectionA gentle introduction to reflection
A gentle introduction to reflection
 

Último

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Usage contracts in a nutshell

  • 1. USAGE CONTRACTS* KIM MENS UNIVERSITÉ CATHOLIQUE DE LOUVAIN (UCL) JOINT WORK WITH ANGELA LOZANO ANDY KELLENS DAGSTUHL SEMINAR – “THE FUTURE OF REFACTORING” LIGHTNING TALK – 21.05.2014 * SLIDES LARGELY BASED ON AN EARLIER PRESENTATION MADE BY ANGELA LOZANO
  • 2. USAGE CONTRACTS /** * Deactivates the tool. This method is called whenever the user switches to another tool * Use this method to do some clean-up when the tool is switched. * Subclassers should always call super.deactivate. * An inactive tool should never be deactivated. */ public void deactivate() { if (isActive()) { if (getActiveView() != null) { getActiveView().setCursor(new AWTCursor(java.awt.Cursor.DEFAULT_CURSOR)); } getEventDispatcher().fireToolDeactivatedEvent(); } } • We want a tool that allows encoding such regularities and offering immediate feedback on violations of such structural source-code regularities • The tool should be proactive (violations reported ‘on the fly’ during coding) • The tool should be “developer-friendly” (like unit testing but for usage expectations) • desired regularities expressed in the same programming language • tight integration with the integrated development environment • not coercive
  • 3. METAPHOR Provider uses Consumer Usage Contract describes expectations of should comply with
  • 4. EXAMPLE copyFrom: anEntity within: aVisitor inherits from copyFrom: anEntity within: aVisitor super copyFrom: anEntity within: aVisitor ... All overriders of copyFrom:within: should start with a super call describes expectations of should comply with
  • 5. EXAMPLE copyFrom: anEntity within: aVisitor inherits from copyFrom: anEntity within: aVisitor super copyFrom: anEntity within: aVisitor ... All overriders of copyFrom:within: should start with a super call describes expectations of should comply with EContract classesInFAMIXSourcedEntityHierarchy <liableHierarchy:#FAMIXSourcedEntity> FAMIXSourcedEntityContract classesInFAMIXSourcedEntityHierarchy copyFromWithinWithCorrectSuperCall Liable entity copyFromWithinWithCorrectSuperCall <selector:#copyFrom:within:> contract require: condition beginsWith: (condition doesSuperSend: #copyFrom:within:) if: (condition isOverridden) Contract term Contract conditions
  • 6. UCONTRACTS : THE LANGUAGE EContract Liable classes •liableClass: regExp / exceptClass: regExp •liableHierarchy: className / exceptHierarchy: className •liablePackage: regExp / exceptPackage: regExp classesInFAMIXSourcedEntityHierarchy <liableHierarchy:#FAMIXSourcedEntity> FAMIXSourcedEntityContract classesInFAMIXSourcedEntityHierarchy copyFromWithinWithCorrectSuperCall Liable entity copyFromWithinWithCorrectSuperCall <selector:#copyFrom:within:> contract require: condition beginsWith: (condition doesSuperSend: #copyFrom:within:) if: (condition isOverridden) Contract term Contract conditions Liable methods •selector: regExp / exceptSelector: regExp •protocol: regExp / exceptProtocol: regExp •/ exceptClass: className selector: selector Contract terms •require: condition •suggest: condition •require: condition if: anotherCondition •suggest: condition if: anotherCondition Contract conditions •assigns: regExp •calls: regExp •references: regExp •returns: expression •doesSuperSend: regExp •doesSelfSend: regExp •inProtocol: regExp •isOverridden: selector •isOverridden •isImplemented: selector •custom: visitor ! •and: cond1 with: cond2 •or: cond1 with: cond2 •not: cond ! •beginsWith: cond •endsWith: cond •does: cond1 after: cond2 •does: cond1 before: cond2