Tammy Dahlgren with Tom Epperly, Scott Kohn, and Gary Kumfert Center for Applied Scientific Computing Common Component Architecture Working Group October.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Advertisements

Program Verification Using the Spec# Programming System ETAPS Tutorial K. Rustan M. Leino, Microsoft Research, Redmond Rosemary Monahan, NUIM Maynooth.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Building Bug-Free O-O Software: An Introduction to Design By Contract A presentation about Design By Contract and the Eiffel software development tool.
Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
Semantics Static semantics Dynamic semantics attribute grammars
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Programming Languages and Paradigms The C Programming Language.
The Java Modeling Language JML Erik Poll Digital Security Radboud University Nijmegen.
Design by Contract ™. 2 Design by Contract A discipline of analysis, design, implementation, management.
Feb 2003 R McFadyen1 Contracts (Ch 13) Used to help understand requirements more completely based on assertions; assertions are applicable to any.
Tammy Dahlgren, Tom Epperly, Scott Kohn, and Gary Kumfert Center for Applied Scientific Computing Common Component Architecture Working Group October 3,
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
Design by Contract. Specifications Correctness formula (Hoare triple) {P} A {Q} – A is some operation (for example, a routine body) – P and Q are predicates.
Jan 2005 Ron McFadyen1 Contracts Used to help understand requirements more completely (and so may not always be necessary) based on assertions;
Bronis R. de Supinski Center for Applied Scientific Computing Lawrence Livermore National Laboratory June 2, 2005 The Most Needed Feature(s) for OpenMP.
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Software Testing and Quality Assurance
Static and Dynamic Contract Verifiers For Java Hongming Liu.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
OOP #10: Correctness Fritz Henglein. Wrap-up: Types A type is a collection of objects with common behavior (operations and properties). (Abstract) types.
1 Dan Quinlan, Markus Schordan, Qing Yi Center for Applied Scientific Computing Lawrence Livermore National Laboratory Semantic-Driven Parallelization.
Describing Syntax and Semantics
Eiffel Language and Design by Contract Contract –An agreement between the client and the supplier Characteristics –Expects some benefits and is prepared.
Sept Ron McFadyen1 Extend Relationship.
Design by Contract Advanced Software Tools Seminar Alexander Freidin 2006 Defining Contracts on Method Call Sequences.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
Abstract data types What does ‘ abstract ’ mean? From Latin: to ‘ pull out ’— the essentials –To defer or hide the details –Abstraction emphasizes essentials.
Component-Based Software Engineering Components and Interfaces Paul Krause.
Ranga Rodrigo. Class is central to object oriented programming.
Programming Languages and Paradigms Object-Oriented Programming.
Implementation Yaodong Bi. Introduction to Implementation Purposes of Implementation – Plan the system integrations required in each iteration – Distribute.
CCA Common Component Architecture CCA Forum Tutorial Working Group Contributors: Language Interoperability Using Gary.
Design by Contract in Java Concept and Comparison.
More About Classes Ranga Rodrigo. Information hiding. Copying objects.
CS 363 Comparative Programming Languages Semantics.
Tammy Dahlgren, Tom Epperly, Scott Kohn, & Gary Kumfert.
Scott Kohn with Tammy Dahlgren, Tom Epperly, and Gary Kumfert Center for Applied Scientific Computing Lawrence Livermore National Laboratory October 2,
Reasoning about programs March CSE 403, Winter 2011, Brun.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
(c) University of Washington13-1 CSC 143 Java Specifications: Programming by Contract Reading: Ch. 5.
1 Devon M. Simmonds, Computer Science Department Design by Contract Devon M. Simmonds Computer Science Department University of North Carolina, Wilmington.
Tammy Dahlgren, Tom Epperly, Scott Kohn, & Gary Kumfert.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
L13: Design by Contract Definition Reliability Correctness Pre- and post-condition Asserts and Exceptions Weak & Strong Conditions Class invariants Conditions.
1 Assertions. 2 A boolean expression or predicate that evaluates to true or false in every state In a program they express constraints on the state that.
Defensive Programming CNS 3370 Copyright 2003, Fresh Sources, Inc.
More About Classes Ranga Rodrigo. Quiz: Question 1 Write the following C++ code in Eiffel. void covert { int i ; float f(1.41) ; i = (int) f ; }
DBC NOTES. Design By Contract l A contract carries mutual obligations and benefits. l The client should only call a routine when the routine’s pre-condition.
1 Exceptions When the Contract is Broken. 2 Definitions A routine call succeeds if it terminates its execution in a state satisfying its contract A routine.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Design by Contract. The Goal Ensure the correctness of our software (correctness) Recover when it is not correct anyway (robustness) Correctness: Assertions.
Performance-Driven Interface Contract Enforcement for Scientific Components 10th International Symposium on Component-Based Software Engineering Medford,
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Chapter 6 CS 3370 – C++ Functions.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Used to help understand requirements more completely
Programming Languages and Paradigms
Programming Paradigms
Specifying Object Interfaces
Java Modeling Language (JML)
Predefined Functions Revisited
Introduction to Programming
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
CSE 1020:Software Development
Presentation transcript:

Tammy Dahlgren with Tom Epperly, Scott Kohn, and Gary Kumfert Center for Applied Scientific Computing Common Component Architecture Working Group October 3, 2002 Introducing Design by Contract to SIDL/Babel This work was performed under the auspices of the U.S. Department of Energy by the University of California, Lawrence Livermore National Laboratory under Contract No. W-7405-Eng-48. UCRL-PRES

TLD 2 CASC Overview Goals Basic Constructs Impact on SIDL/Babel Benefits for the CCA Future Work

TLD 3 CASC Why support assertions at the interface specification level? The interface specification can provide a simple, concise description of the requirements, behavior, and constraints. Generated code will automatically ensure compliance regardless of the underlying implementation language.

TLD 4 CASC The SIDL grammar defines packages, interfaces, etc. Packages & Versions Interfaces & Classes Inheritance Model Methods Method Modifiers Intrinsic Data Types Parameter Modes And more… Optional assertion specifications added here

TLD 5 CASC There are several types of assertions mentioned in the literature. TypeExpress… Precondition Constraints to enable proper method function Conditions that must be true prior to invocation Postcondition Guarantees of proper method function Conditions that must be true after invocation Class Invariant Global properties of instances that must be true upon instance creation and preserved by all routines before and after every invocation Loop Invariant Instance properties that must be true prior to the first execution of a loop and preserved by every iteration so hold on loop termination Loop Variant An integer value that must be non-negative prior to first execution of a loop and decreased by every iteration to guarantee loop termination

TLD 6 CASC Only the first two Design by Contract clauses will be added at this time. ClauseComment Preconditions Specify library’s requirements Obligations on callers Postconditions Specify library’s guarantees Obligations on callee to provided preconditions were satisfied and no exceptions raised Method sequencing will be implemented using a sequence, or state, clause the values of which can be utilized in the pre- and post-conditions to specify method ordering.

TLD 7 CASC The new clauses require a number of additions to the SIDL grammar. Eiffel keywords —Preconditionsrequires —Postconditionsensures Simple conditional expression operators —Logical&&, ||, ! —Bitwise Logical&, ^, | —Relational =, > —Shift > —Additive+, - —Multiplicative*, /, % Logical grouping() Literal keywords TRUE, FALSE, NULL, return Terminals

TLD 8 CASC The following specification snippet illustrates the use of both clauses in SIDL. interface Vector { Vector axpy (in Vector a, in Vector x) { requires a != NULL; x != NULL; ensures return != NULL; }; double norm () { ensures return >= 0.0; }; Vector.sidl Recall: If method raises an exception then no guarantee the ensures will be met!

TLD 9 CASC If method sequencing were incorporated, call ordering state would be added. interface Vector { state { uninitialized, initialized }; void setData (in double data){ requires uninitialized; ensures initialized; }; … VectorWithOrdering.sidl Note: Sequencing constructs subject to change. First item is the initial state. Transition to initialized is automatic if library call is successful and all (other) postcondition entries met.

TLD 10 CASC Methods that require the instance to be in a state could annotate it accordingly. interface Vector { … Vector axpy (in Vector a, in Vector x) { requires initialized; a != NULL; x != NULL; ensures return != NULL; }; double norm () { requires initialized; ensures return >= 0.0; }; VectorWithOrdering.sidl Note: Sequencing constructs subject to change.

TLD 11 CASC Babel takes a SIDL file and will generate expanded glue code. Application Impls Stubs Skels IORs SIDL interface description Enforcement code added here.

TLD 12 CASC The IOR files will be changed to add the generated checks. Vector.sidlfoo.f Vector_IOR.c Vector_IOR.hVector_fSkel.cVector.fifVector_Impl.fVector_fStub.c

TLD 13 CASC There will be three execution paths available through the IOR. Call Preconditions Postconditions Return Library method 1 2 3

TLD 14 CASC Dynamic switching between paths can be available at up to four levels. Instance —Vector.__create(/* desired setting */); —Vector.__noChecks();// Path #1 —Vector.__checkRequires();// Path #2 —Vector.__checkAsserts();// Path #3 Class-- For all instances of a class Package-- For a subset of packages Global-- Through the SIDL Loader What degree of flexibility is needed? - Dynamic switching at the Class level? Package level? Loader level? - Regular expression support for specifying classes? Packages?

TLD 15 CASC Violations of assertions will result in the raising of new SIDL exceptions. getNote(): string setNote(string) getTrace():string add[Line](string) add(string, int, string) BaseException RequiresViolation EnsuresViolation One or more requires conditions failed! One or more ensures conditions failed!

TLD 16 CASC Which means several parser-related files must change in the compiler. FileChange(s) dtds/ SIDL.dtd Add elements for the assertion lists and conditions. parsers/sidl/ SIDL.jj Add support for the new grammar productions. parsers/xml/ ParseSymbolXML.java Add parsing for new structures from XML. symbols/ Method.java Add support for assertion lists. symbols/ newclass(es).java New file(s) associated with the assertion list productions to support the lists.

TLD 17 CASC The backends must also be modified to support the IOR and stub changes. FilesChange(s) backend/IOR.java backend/IOR/IORHeader.java backend/IOR/IORSource.java Add support for new built-in methods for dynamic switching and the new entry point vectors. backend/language/StubHeader.java* backend/language/StubSource.java* Add support for new built-in methods for dynamic switching. * These or their equivalent are generally present for each supported language.

TLD 18 CASC Interface-level assertions will ultimately facilitate wider reuse of CCA Components! For Domain Scientists, components will be: + well-debugged + well-documented + easier to use For Library developers: + requirements explicit + constraints explicit + sequencing explicit + automatic enforcement + enhanced debugging

TLD 19 CASC Future work focuses on adding and exploring more features. Add support for specifying and enforcing method sequencing Explore annotations and mechanisms for: —Enabling the use of a method within assertions (e.g., const or immutable) —Checking features of an instance (e.g., comparing sizes of two matrices or vectors) —Integrating and checking relevant domain-specific properties (e.g., standard units, types of matrices) – Automated determination of compatibility – Generation and automated use of translation routines Anything else?