USAGE CONTRACTS* 
KIM MENS 
UNIVERSITÉ CATHOLIQUE DE LOUVAIN (UCL) 
JOINT WORK WITH 
ANGELA LOZANO 
ANDY KELLENS 
SATTOSE 2014 – L’AQUILA – 9-11.07.2014 
* SLIDES LARGELY BASED ON AN EARLIER PRESENTATION MADE BY ANGELA LOZANO
SOME OF MY 
RESEARCH INTERESTS 
Programming languages 
Context-Oriented Programming 
Language interoperability between logic and OO 
(Aspect-oriented programming ✞) 
Tool support for software development, maintenance and evolution 
source code mining 
source-code based recommendation tools 
structural source-code regularities (e.g. usage contracts)
USAGE CONTRACTS : MOTIVATION 
Often you find code comments like 
! 
! 
! 
! 
! 
! 
! 
! 
! 
! 
/** 
* 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(); 
} 
}
USAGE CONTRACTS : MOTIVATION 
Often you find code comments like 
! 
! 
! 
! 
We studied JHotDraw for occurrences of “should, may, must, can(not), could, 
ought, have, has, need, require, ….” and found 22 structural regularities like : 
! 
! 
! 
! 
! 
/** 
* 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(); 
} 
} 
subclassers of this class should call … 
this class should not do a supercall 
… must implement … 
should (not) override 
methods in this class … only be called by … 
this method only be called internally 
be called after …
USAGE CONTRACTS : GOAL 
/** 
* 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
VALIDATION ON AN 
INDUSTRIAL CASE 
• An interactive web application for event & resource planning 
• developed in Pharo Smalltalk 
• uses the Seaside web development framework. 
• Medium-sized 
• Packages: 45 
• Classes: 827 
• Methods: 11777 
• LOCs: 94151
INDUSTRIAL VALIDATION : 
SET-UP OF THE EXPERIMENT 
• Qualitative assessment 
• Ideally we would have liked the tool to be used directly by the 
developers, but instead we had to perform an offline experiment. 
• Together with the developers, during 2 days we defined 13 
contracts documenting important regularities in their framework 
• We checked all contracts in December and reported all contract 
breaches to the developers 
• 3 months later, we reverified compliance of the code against the 
same contracts
INDUSTRIAL VALIDATION : 
ABOUT THE CONTRACTS 
• contracts related to the model of the web application 
• for 3/5 of them violations were found 
• 214 liable classes, 88 violations 
• contracts related to the classes dealing with persistency 
• for 2/2 of them violations where found 
• 75 liable classes, 2 violations found 
• contracts about how the UI is constructed with the Seaside framework 
• for 4/6 of them violations where found 
• 598 liable classes, 8 violations found
INDUSTRIAL VALIDATION : 
EXAMPLE OF A CONTRACT 
Private methods should not be called directly 
liable classes 
contract
INDUSTRIAL VALIDATION : 
EXAMPLE OF A CONTRACT 
In domain classes, state changes must mark model 
objects as dirty so that they can be re-rendered 
liable classes 
contract
INDUSTRIAL VALIDATION : 
EXAMPLE OF A CONTRACT 
Overridden initialisation methods should start with a 
super call (and be put in an appropriate protocol) 
liable classes 
contract
INDUSTRIAL VALIDATION : 
EXAMPLE OF A CONTRACT 
Certain messages need to be sent at the end of a 
method cascade liable classes 
contract
INDUSTRIAL VALIDATION : 
EXAMPLE OF A CONTRACT 
Certain messages need to be sent at the end of a 
method cascade liable classes 
contract 
contract 
WithInCascadeVisitor extends CustomConditionVisitor
INDUSTRIAL VALIDATION : 
RESULTS 
Contract Liable Methods Exceptions 
Errors 
December 
Errors 
March 
Private methods 
should not be 
called directly 
7410 0 3 2 
Marking dirty 
objects 333 5 7 2 
Initialisation 
methods should 
44 0 1 0 
start with super 
Call ordering 
within method 
cascade 
531 0 0 0
UCONTRACTS : CONCLUSION 
• uContracts offer a simple unit-testing like way for letting programmers 
document and check conformance to structural source-code regularities 
• using a “contract” metaphor 
• focus on immediate feedback during development 
• embedded DSL close to the programming language 
• tight integration with the IDE 
• Publication pending: A. Lozano, K. Mens, and A. Kellens, “Usage 
contracts: offering immediate feed- back on violations of structural 
source-code regularities”. (submitted to SciCo)
FUTURE WORK 
• More validation 
• Improve / extend the DSL 
• Port to most recent version of Pharo 
• uContracts for other languages (e.g., Ruby)

More Related Content

PDF
Documenting Bugs in Doxygen
PPTX
SAST_QSDL
PPTX
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
PDF
Pragmatic Code Coverage
PDF
基於 Flow & Path 的 MVP 架構
PDF
Android with dagger_2
PDF
Presentation slides: "How to get 100% code coverage"
PDF
Living With Legacy Code
Documenting Bugs in Doxygen
SAST_QSDL
Code Coverage and Test Suite Effectiveness: Empirical Study with Real Bugs in...
Pragmatic Code Coverage
基於 Flow & Path 的 MVP 架構
Android with dagger_2
Presentation slides: "How to get 100% code coverage"
Living With Legacy Code

What's hot (18)

PPTX
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
PPTX
Software testing ... who’s responsible is it?
KEY
iOS Unit Testing
PDF
Errors detected in the Visual C++ 2012 libraries
PDF
Performance Testing | Instamojo
PDF
Hyper-pragmatic Pure FP testing with distage-testkit
PDF
ScalaUA - distage: Staged Dependency Injection
PDF
Checking Clang 11 with PVS-Studio
PDF
Write testable code in java, best practices
PDF
PVS-Studio advertisement - static analysis of C/C++ code
PDF
Date Processing Attracts Bugs or 77 Defects in Qt 6
PDF
Write readable tests
PPTX
TDD and the Legacy Code Black Hole
PDF
How penetration testing techniques can help you improve your qa skills
PDF
Looking for Bugs in MonoDevelop
PDF
Writing testable Android apps
PDF
A Long-Awaited Check of Unreal Engine 4
PDF
Izumi 1.0: Your Next Scala Stack
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
Software testing ... who’s responsible is it?
iOS Unit Testing
Errors detected in the Visual C++ 2012 libraries
Performance Testing | Instamojo
Hyper-pragmatic Pure FP testing with distage-testkit
ScalaUA - distage: Staged Dependency Injection
Checking Clang 11 with PVS-Studio
Write testable code in java, best practices
PVS-Studio advertisement - static analysis of C/C++ code
Date Processing Attracts Bugs or 77 Defects in Qt 6
Write readable tests
TDD and the Legacy Code Black Hole
How penetration testing techniques can help you improve your qa skills
Looking for Bugs in MonoDevelop
Writing testable Android apps
A Long-Awaited Check of Unreal Engine 4
Izumi 1.0: Your Next Scala Stack
Ad

Viewers also liked (8)

PPTX
Ppp 206
PDF
Content ux processes_idw_2014_final
PDF
The Responsive Bank. Feature article in Q factor Oct 2014
PPT
Metric edge final 1
PDF
Freshmail - Pomysly na efektywne mailingi
PDF
University of madras notice
PDF
Designer wanted
PDF
A Strategic Control Module for a Corporate Model of British Telecom
Ppp 206
Content ux processes_idw_2014_final
The Responsive Bank. Feature article in Q factor Oct 2014
Metric edge final 1
Freshmail - Pomysly na efektywne mailingi
University of madras notice
Designer wanted
A Strategic Control Module for a Corporate Model of British Telecom
Ad

Similar to Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy) (20)

PDF
Usage contracts in a nutshell
PDF
Dependency Injection
PDF
UContracts a DSL to document and validate structural requirements of frameworks
PDF
Framework Agnostic Discovery
PPTX
Intro to Automation Using Perfecto's CQ Lab
PPTX
Leveraging Dependency Injection(DI) in Universal Applications - Tamir Dresher
PPTX
Rock Your Code With Code Contracts -2013
PDF
TDD for Microservices
PDF
Fragility in evolving software
PPTX
Clean Code Part II - Dependency Injection at SoCal Code Camp
PPTX
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
PPTX
DDD, CQRS and testing with ASP.Net MVC
PDF
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
PPTX
Workshop: .NET Code Contracts
PDF
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
PDF
Increasing productivity with continuous delivery
PDF
Preparing for DevOps
PPTX
Slides1 - testing
PDF
Centralize and Simplify Secrets Management for Red Hat OpenShift Container En...
PPTX
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Usage contracts in a nutshell
Dependency Injection
UContracts a DSL to document and validate structural requirements of frameworks
Framework Agnostic Discovery
Intro to Automation Using Perfecto's CQ Lab
Leveraging Dependency Injection(DI) in Universal Applications - Tamir Dresher
Rock Your Code With Code Contracts -2013
TDD for Microservices
Fragility in evolving software
Clean Code Part II - Dependency Injection at SoCal Code Camp
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
DDD, CQRS and testing with ASP.Net MVC
Automatically Managing Service Dependencies in an OSGi Environment - Marcel O...
Workshop: .NET Code Contracts
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
Increasing productivity with continuous delivery
Preparing for DevOps
Slides1 - testing
Centralize and Simplify Secrets Management for Red Hat OpenShift Container En...
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck

More from kim.mens (20)

PDF
Software Maintenance and Evolution
PDF
Context-Oriented Programming
PDF
Software Reuse and Object-Oriented Programming
PDF
Bad Code Smells
PDF
Object-Oriented Design Heuristics
PDF
Software Patterns
PDF
Code Refactoring
PDF
Domain Modelling
PDF
Object-Oriented Application Frameworks
PDF
Towards a Context-Oriented Software Implementation Framework
PDF
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
PDF
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
PDF
Context-oriented programming
PDF
Basics of reflection
PDF
Advanced Reflection in Java
PDF
Basics of reflection in java
PDF
Reflection in Ruby
PDF
Introduction to Ruby
PDF
Introduction to Smalltalk
PDF
A gentle introduction to reflection
Software Maintenance and Evolution
Context-Oriented Programming
Software Reuse and Object-Oriented Programming
Bad Code Smells
Object-Oriented Design Heuristics
Software Patterns
Code Refactoring
Domain Modelling
Object-Oriented Application Frameworks
Towards a Context-Oriented Software Implementation Framework
Towards a Taxonomy of Context-Aware Software Variabilty Approaches
Breaking the Walls: A Unified Vision on Context-Oriented Software Engineering
Context-oriented programming
Basics of reflection
Advanced Reflection in Java
Basics of reflection in java
Reflection in Ruby
Introduction to Ruby
Introduction to Smalltalk
A gentle introduction to reflection

Recently uploaded (20)

PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PPTX
Modernising the Digital Integration Hub
PDF
Five Habits of High-Impact Board Members
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Architecture types and enterprise applications.pdf
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPTX
The various Industrial Revolutions .pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPT
What is a Computer? Input Devices /output devices
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Modernising the Digital Integration Hub
Five Habits of High-Impact Board Members
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Architecture types and enterprise applications.pdf
A review of recent deep learning applications in wood surface defect identifi...
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Chapter 5: Probability Theory and Statistics
Zenith AI: Advanced Artificial Intelligence
The influence of sentiment analysis in enhancing early warning system model f...
Credit Without Borders: AI and Financial Inclusion in Bangladesh
The various Industrial Revolutions .pptx
1 - Historical Antecedents, Social Consideration.pdf
2018-HIPAA-Renewal-Training for executives
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Getting started with AI Agents and Multi-Agent Systems
sustainability-14-14877-v2.pddhzftheheeeee
What is a Computer? Input Devices /output devices

Usage contracts (presented at SATToSE 2014 in L'Aquila, Italy)

  • 1. USAGE CONTRACTS* KIM MENS UNIVERSITÉ CATHOLIQUE DE LOUVAIN (UCL) JOINT WORK WITH ANGELA LOZANO ANDY KELLENS SATTOSE 2014 – L’AQUILA – 9-11.07.2014 * SLIDES LARGELY BASED ON AN EARLIER PRESENTATION MADE BY ANGELA LOZANO
  • 2. SOME OF MY RESEARCH INTERESTS Programming languages Context-Oriented Programming Language interoperability between logic and OO (Aspect-oriented programming ✞) Tool support for software development, maintenance and evolution source code mining source-code based recommendation tools structural source-code regularities (e.g. usage contracts)
  • 3. USAGE CONTRACTS : MOTIVATION Often you find code comments like ! ! ! ! ! ! ! ! ! ! /** * 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(); } }
  • 4. USAGE CONTRACTS : MOTIVATION Often you find code comments like ! ! ! ! We studied JHotDraw for occurrences of “should, may, must, can(not), could, ought, have, has, need, require, ….” and found 22 structural regularities like : ! ! ! ! ! /** * 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(); } } subclassers of this class should call … this class should not do a supercall … must implement … should (not) override methods in this class … only be called by … this method only be called internally be called after …
  • 5. USAGE CONTRACTS : GOAL /** * 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
  • 6. METAPHOR Provider uses Consumer Usage Contract describes expectations of should comply with
  • 7. 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
  • 8. 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
  • 9. 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
  • 11. VALIDATION ON AN INDUSTRIAL CASE • An interactive web application for event & resource planning • developed in Pharo Smalltalk • uses the Seaside web development framework. • Medium-sized • Packages: 45 • Classes: 827 • Methods: 11777 • LOCs: 94151
  • 12. INDUSTRIAL VALIDATION : SET-UP OF THE EXPERIMENT • Qualitative assessment • Ideally we would have liked the tool to be used directly by the developers, but instead we had to perform an offline experiment. • Together with the developers, during 2 days we defined 13 contracts documenting important regularities in their framework • We checked all contracts in December and reported all contract breaches to the developers • 3 months later, we reverified compliance of the code against the same contracts
  • 13. INDUSTRIAL VALIDATION : ABOUT THE CONTRACTS • contracts related to the model of the web application • for 3/5 of them violations were found • 214 liable classes, 88 violations • contracts related to the classes dealing with persistency • for 2/2 of them violations where found • 75 liable classes, 2 violations found • contracts about how the UI is constructed with the Seaside framework • for 4/6 of them violations where found • 598 liable classes, 8 violations found
  • 14. INDUSTRIAL VALIDATION : EXAMPLE OF A CONTRACT Private methods should not be called directly liable classes contract
  • 15. INDUSTRIAL VALIDATION : EXAMPLE OF A CONTRACT In domain classes, state changes must mark model objects as dirty so that they can be re-rendered liable classes contract
  • 16. INDUSTRIAL VALIDATION : EXAMPLE OF A CONTRACT Overridden initialisation methods should start with a super call (and be put in an appropriate protocol) liable classes contract
  • 17. INDUSTRIAL VALIDATION : EXAMPLE OF A CONTRACT Certain messages need to be sent at the end of a method cascade liable classes contract
  • 18. INDUSTRIAL VALIDATION : EXAMPLE OF A CONTRACT Certain messages need to be sent at the end of a method cascade liable classes contract contract WithInCascadeVisitor extends CustomConditionVisitor
  • 19. INDUSTRIAL VALIDATION : RESULTS Contract Liable Methods Exceptions Errors December Errors March Private methods should not be called directly 7410 0 3 2 Marking dirty objects 333 5 7 2 Initialisation methods should 44 0 1 0 start with super Call ordering within method cascade 531 0 0 0
  • 20. UCONTRACTS : CONCLUSION • uContracts offer a simple unit-testing like way for letting programmers document and check conformance to structural source-code regularities • using a “contract” metaphor • focus on immediate feedback during development • embedded DSL close to the programming language • tight integration with the IDE • Publication pending: A. Lozano, K. Mens, and A. Kellens, “Usage contracts: offering immediate feed- back on violations of structural source-code regularities”. (submitted to SciCo)
  • 21. FUTURE WORK • More validation • Improve / extend the DSL • Port to most recent version of Pharo • uContracts for other languages (e.g., Ruby)