OOSC - JMSAssert. Design By Contract A powerful technique for writing reliable software. Specifying the software purpose with the implementation. Key.

Slides:



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

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
COP 3530 JDK Environment Variables. COP 3530 JDK Environment Variables Environment Variables Environment variables are a set of dynamic values that can.
Design By Contract Using JMSAssert.
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
1. Define the concept of assertions. 1 Explain the use of assertions. 2 Create Java program using assertions. 3 Run Java program using assertions. 4 2.
Practice Session 5 Java: Packages Collection Classes Iterators Generics Design by Contract Test Driven Development JUnit.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
ANT: Another Nice Tool Ali Beyad October 1, 2003.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
The Java Assert Statement. 2 Assert A Java statement in JDK 1.4 & newer Intent: enables code to test assumptions. E.g., a method that calculates a particle’s.
1 Introduction to Java and Applet. 2 Download Java Compiler (1)
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
Software Testing and Quality Assurance
Integrated Development Environments. Today We Will: Go over more advanced functionality of Eclipse. Break up into teams to work on presentation and final.
Static and Dynamic Contract Verifiers For Java Hongming Liu.
Object-Oriented Enterprise Application Development Javadoc Last Updated: 06/30/2001.
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Winter 2005Jason Prideaux1 Apache ANT A platform independent build tool for Java programs.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Page 1 Building Reliable Component-based Systems Chapter 6 - Semantic Integrity in Component Based Development Chapter 6 Semantic Integrity in Component.
Chair of Software Engineering Automatic Verification of Computer Programs.
COMPILING JAVA PROGRAM USING JDK COMMAND LINE WINDOWS PLATFORM.
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.
Computer Science 340 Software Design & Testing Design By Contract.
Component-Based Software Engineering Components and Interfaces Paul Krause.
Ranga Rodrigo. Class is central to object oriented programming.
CS 240 Week 3. List’Em java Grep [-r] directoryName fileSelectionPattern substringSelectionPattern Run Demo java LineCount [-r] directoryName fileSelectionPattern.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
Tammy Dahlgren with Tom Epperly, Scott Kohn, and Gary Kumfert Center for Applied Scientific Computing Common Component Architecture Working Group October.
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
Design by Contract in Java Concept and Comparison.
The Daikon system for dynamic detection of likely invariants MIT Computer Science and Artificial Intelligence Lab. 16 January 2007 Presented by Chervet.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.
Pre- and postconditions, Using assertions and exceptions 1 Pre- and postconditions Using assertions and exceptions.
JavaDoc and Contracts Spring Documenting Contracts with JavaDoc Contract model for methods Preconditions Postconditions JavaDoc Industry standard.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
Georgia Institute of Technology Creating Classes part 4 Barb Ericson Georgia Institute of Technology May 2006.
CreatingClasses-SlideShow-part41 Creating Classes part 4 Barb Ericson Georgia Institute of Technology Dec 2009.
Protocols Software Engineering II Wirfs Brock et al, Designing Object-Oriented Software, Prentice Hall, Mitchell, R., and McKim, Design by Contract,
Verificare şi Validarea Sistemelor Soft Tem ă Laborator 1 ESC/Java2 Extended Static Checker for Java Dat ă primire laborator: Lab 1 Dat ă predare laborator:
Computer Science 209 Software Development Handing Errors and Creating Documentation.
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.
OOSC – Lab 1. Welcome Object Oriented programming is first and foremost a method for software construction, whose goal is to build high-quality software.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Documentation Javadocs. Design/Documentation An essential ingredient of good Object Oriented programming is known as design by contract. This means that.
The Java Assertion. 2 Assertion A Java statement in JDK 1.4 & newer Intent: enables code to test assumptions. E.g., a method that calculates the a particle’s.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Chapter 7 Programming by contract: preconditions and postconditions.
Generics. Writing typed checked generic code There are many instances where the type of the object is irrelevant : –The construction of data structures.
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.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Class Invariants Class invariants are logical conditions to ensure the correct working of a class. Class invariants must hold true when an object is created,
SWEN421 – Lecture 3 Building High Integrity Software with SPARK Ada
Specifying Object Interfaces
Introduction to Data Structures
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
Design by contract Object-Oriented Software Construction by Bertrand Meyer, Prentice Hall The presence of a precondition or postcondition in a routine.
JavaDoc and Contracts Fall 2008.
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
Applying OO Concepts Using Java
Java Modeling Language (JML)
Generics, Lambdas and Reflection
Presentation transcript:

OOSC - JMSAssert

Design By Contract A powerful technique for writing reliable software. Specifying the software purpose with the implementation. Key elements: Invariant Preconditions Postconditions

Design By Contract Precondition – The constraints under which the routine will function properly. Postconditions – The state of the class after the routine execution The Contract: If you call routine R() with the preconditions satisfied, R() will return satisfying the postconditions. Invariant – Always holds

When are condition checked?

JMS Syntax - Invariant Invariant May access all class members or its direct/indirect bases, including private members May appear in any JavaDoc comment Preferable in the class comment

JMS Syntax - Preconditions Precondition JavaDoc preceding the respective method May reference class members and arguments markers are conjugated (AND)

JMS Syntax - Postconditions Postconditions JavaDoc preceding the respective method May use $prev(expression) to access the value at the method entry. May use $ret to denote method’s return value markers are conjugated (AND)

Example /** !isEmpty() (top == $prev(top- 1)) $ret == elems[top] !isFull */ public synchronized Object pop() { return elems[--top]; } Precondition Postconditions

JMS Syntax - General Order has no – for complicated conditions Recursion – as expected, on every call Inner classes can access outer classes’ members Anonymous classes – specify invariant in one of its methods

JMSAssert Installation Run the jmssetup-1.02.exe installation file The following lines are added to the path: REM Next two lines are added by JMSAssert SET CLASSPATH=%CLASSPATH%;C:\PROGRA~1\JMSASS~1.0\ bin\mmsclasses.jar; SET PATH=%PATH%;C:\PROGRA~1\JMSASS~1.0\bin; Copy the “ classic ” directory from “..\jdk1.3.1\jre\bin\ ” to the directory: “C:\Program Files\JavaSoft\JRE\1.3\bin\”

Setup (cont.) Your JavaSoft directory should look like: If you use jdk 1.2.2, you will have a 1.2 directory

JMSAssert – how does it work Annotate source code with assertions Compile your code using javac (as usual) Preprocess the code using jmsassert: creates contract files ( *.jms ) and a Startup.jms file. *.jms files contain java code for the assertions. Execute using: jmsjava Startup to check assertions. jmsjava makes sure method assertions are called before/after the method invocation.

JMS Execution “ jmsassert ” – generates help text “ jmsassert –s ” – generate assertions for a class file “ jmsassert –r –s. ” – generate assertions for all class files in the directory and sub-dirs. (use for packages) “ javac ” – compile “ jmsjava Startup ” - execute and check assertions

Annotate source with assertions Preprocess to generate assertion files Jmsassert –s Compile Java file javac Execute using jmsjava MyStack.java Startup.jms default_MyStack.jms default_MyStack_StackEnum.jms MyStack.class MyStack$StackEnum.class Jmsjava Startup StackTest.class Stack Demo files Execution process

Notes Execute these steps form the command line! Make sure your CLASSPATH environment variable contains the current directory. Add “ CLASSPATH=%CLASSPATH%;.; ” to autoexec.bat.