TIVDM2Model Quality1 Peter Gorm Larsen. TIVDM2Model Quality2 Agenda  Introduction Internal Consistency External Consistency.

Slides:



Advertisements
Similar presentations
Chapter 17 Failures and exceptions. This chapter discusses n Failure. n The meaning of system failure. n Causes of failure. n Handling failure. n Exception.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
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.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 8.
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
Java Script Session1 INTRODUCTION.
Java Card Technology Ch07: Applet Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Computer Science & Engineering.
Data Abstraction II SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
Utilities (Part 3) Implementing static features 1.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Road Map Introduction to object oriented programming. Classes
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.
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.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
Modular Programming and Use Case Models Session 3 LBSC 790 / INFM 718B Building the Human-Computer Interface.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 7 User-Defined Methods.
Describing Syntax and Semantics
Ranga Rodrigo. Class is central to object oriented programming.
VDMUnit Testing, Combinatorial Testing, Model Quality and Code Generation Professor Peter Gorm Larsen Department of Engineering, Aarhus University
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
Cs2220: Engineering Software Class 8: Implementing Data Abstractions Fall 2010 University of Virginia David Evans.
VDM++ Tutorial Implementing in Java. Overview Introduction Overview of Java code generation Options for Java code generation Keep tags POP3 Example.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
The Java Programming Language
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 8 Objects and Classes.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
TIVDM1Modelling ordered collections1 Peter Gorm Larsen.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
TIVDM1Modelling unordered collections1 Peter Gorm Larsen.
VDM++ Tutorial Model Quality. Overview Introduction Assessing internal consistency Assessing external consistency.
Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.
Validating Requirements Determining Completeness and Correctness of Requirements Using the System Reference Model IV&V Workshop 16 September 2009.
CSC1401 Classes - 2. Learning Goals Computing concepts Adding a method To show the pictures in the slide show Creating accessors and modifiers That protect.
Cairngorm Microarchitecture. Pronunciation Cairngorm (kârn gôrm) n. yellowish-brown variety of quartz, especially found in Scottish Cairngorm mountain.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Chapter 3 Part II Describing Syntax and Semantics.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Inheritance (Part 2) KomondorBloodHound PureBreedMix Dog Object.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
CS305j Introduction to Computing Classes II 1 Topic 24 Classes Part II "Object-oriented programming as it emerged in Simula 67 allows software structure.
L13: Design by Contract Definition Reliability Correctness Pre- and post-condition Asserts and Exceptions Weak & Strong Conditions Class invariants Conditions.
VDM++ Tutorial Concurrency. Overview Introduction Concurrency primitives in VDM++ Example: POP3 Server Concurrency and VDMTools ®
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Chapter 6 - More About Problem Domain Classes1 Chapter 6 More About Problem Domain Classes.
Chapter 7 Programming by contract: preconditions and postconditions.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
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.
Cs205: engineering software university of virginia fall 2006 Programming Exceptionally David Evans
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Winter 2006CISC121 - Prof. McLeod1 Stuff Midterm exam in JEF234 on March 9th from 7- 9pm.
Chapter 6 CS 3370 – C++ Functions.
“Form Ever Follows Function” Louis Henri Sullivan
Chapter No. : 1 Introduction to Java.
Logger, Assert and Invariants
Java Primer 1: Types, Classes and Operators
CS360 Windows Programming
Chapter 1: Computer Systems
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.
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Presentation transcript:

TIVDM2Model Quality1 Peter Gorm Larsen

TIVDM2Model Quality2 Agenda  Introduction Internal Consistency External Consistency

TIVDM2Model Quality3 Introduction What is now the value of the models you have produced? How do we assess the quality of a model? Internal consistency: Does the model describe something? Syntax, type checking and proof obligations No potential run-time errors External consistency: Does the model describe the right thing? Validation with domain expert Does the model have desirable properties?

TIVDM2Model Quality4 Agenda Introduction  Internal Consistency External Consistency

TIVDM2Model Quality5 POP3: Protection of Partial Operators class POP3Server... instance variables maildrop : MailDrop;... types public MailDrop = map POP3Types`UserName to MailBox; public MailBox :: msgs : seq of POP3Message locked : bool; operations GetUserMessages: POP3Types`UserName ==> seq of POP3Message GetUserMessages(user) == return GetUserMail(user).msgs pre UserKnown(user); end POP3Server

TIVDM2Model Quality6 Booking of Flights: Invariant Preservation class Trip types Flight :: departure : seq of char destination : seq of char instance variables journey: seq of Flight; inv forall i in set {1,...,len journey -1} & journey(i).destination = journey(i+1).departure operations AddFlight: Flight ==> () AddFlight(f) == journey := journey ^ [f] pre journey(len journey).destination = f.departure end Trip journey <> [] =>

TIVDM2Model Quality7 Robot Routes: Satisfiability 1 class Route instance variables points: set of Point; inv forall p1, p2 in set points & p1.GetCoord() = p2.GetCoord() => p1 = p2 and forall p in set points & p.GetIndex() <> card points => GetNext(p).GetCoord() in set {n.GetCoord() | n in set p.Neighbour()} … end Route

TIVDM2Model Quality8 Robot Routes: Satisfiability 2 class Route functions static public AvoidanceRoutes( obstacles: set of (nat * nat), currentPosition: Point, nextWaypoint: Point) routes: set of Route post forall r in set routes & r.GetFirst().GetCoord() = currentPosition.GetCoord() and r.GetLast().GetCoord() = nextWaypoint.GetCoord() and r.GetCoords() inter obstacles = {}; end Route

TIVDM2Model Quality9 Robot Routes: Satisfiability 3 For implicit definitions there must exist at least one potential result for each input satisfying the pre-condition Proof Obligation (or integrity constraint): forall obstacles: set of (nat * nat), currentPosition: Point, nextWaypoint: Point & exists routes: set of Route & post-AvoidanceRoutes(obstances,currentPosition, nextWaypoint,routes) Can in principle be proved formally

TIVDM2Model Quality10 Agenda Introduction Internal Consistency  External Consistency

TIVDM2Model Quality11 Dialogue with Domain Experts Typically domain experts know little about IT Understanding their intended usage may be a challenge Creating a model will create further questions to experts Model should seldomly been shown directly Scenarios to be used for test purposes can typically be discussed A CORBA-based API can be used to ”demonstrate” ideas to domain experts/end users

TIVDM2Model Quality12 Syntax, type check and Execute using API Example model to use: class A operations public op: int ==> int op(n) == return n + 1 pre n > 0 end A

TIVDM2Model Quality13 The CORBA API for VDMTools The class ToolboxClient shall be used Includes the getVDMApplication method Result must be casted to VDMApplication In Java this would look like: ToolboxClient toolboxClient = new ToolboxClient(); org.omg.CORBA.Object obj = toolboxClient.getVDMApplication( new String[]{}, ToolType.PP_TOOLBOX); app = VDMApplicationHelper.narrow(obj); Additional initialization: client = app.Register(); app.PushTag(client);

TIVDM2Model Quality14 Interacting with the API: Syntax and Type Checking VDMProject prj = app.GetProject(); prj.New(); String path = "/local/vdm++book/validation"; String[] modelFiles = {"A.vpp"}; VDMParser parser = app.GetParser(); for (int i = 0; i < modelFiles.length; i++) { String filename = path + "/" + modelFiles[i]; prj.AddFile(filename); parser.Parse(filename); } private void typeCheck() throws APIError { ModuleListHolder moduleList = new ModuleListHolder(); app.GetProject().GetModules(moduleList); app.GetTypeChecker().TypeCheckList(moduleList.value); }

TIVDM2Model Quality15 Interacting with the API: Execution VDMInterpreter interp = app.GetInterpreter(); interp.Initialize (); interp.EvalCmd("create a := new A()"); try { VDMFactory fact = app.GetVDMFactory(); VDMSequence args = fact.MkSequence(client); VDMNumeric intValue = fact.MkNumeric(client, 5); args.ImpAppend(intValue); VDMGeneric result = interp.Apply(client, "a.op", args); System.out.println("Result is " + result.ToAscii()); } catch (APIError e) { System.err.println("Unable to validate model"); }

TIVDM2Model Quality16 Validating POP3 using the API

TIVDM2Model Quality17 Class Diagram for API GUI Layer

TIVDM2Model Quality18 Interacting with One Client Pop3APILayer defined a number of fields: VDMApplication app : This is a CORBA reference to the running VDMTools instance. VDMInterpreter interp : This is a CORBA reference to the interpreter in the instance of the VDMTools to which app refers. short client : The identifier number allocated by the VDMTools to this client. JTextArea logArea : A reference to a Java swing text area object, used to show the dialogue between the client and VDMTools. String channel : The name of the channel that will be used within the interpreter for communication with the server.

TIVDM2Model Quality19 Initializing the Interpreter private void initInterpreter() throws APIError { // Ensure echoing in interpreter interp.Verbose(true); // Enable precondition checking during execution interp.DynPreCheck(true); interp.Initialize (); EvalCmd("create ch := new MessageChannelBuffer()"); EvalCmd("create pt := new POP3Test()"); EvalCmd("create server := " + "new POP3Server(pt.Mak Drop(), " + "ch,pt.MakePasswordMap())"); EvalCmd("debug pt.StartServer(server)"); }

TIVDM2Model Quality20 Interaction between Client and Server public boolean openServerConnection(String username,String password, StringBuffer response) { try { EvalCmd("create " + channel + " := new MessageChannel()"); EvalCmd("debug ch.Put(" + channel + ")"); boolean status = executeCommand("USER", new String[]{"\""+username+"\""}, response); if (!status) return false; status = executeCommand("PASS", new String[]{"\""+password+"\""}, response); return status; } catch (Exception e) { e.printStackTrace(System.err); return false; } }

TIVDM2Model Quality21 Executing Commands private boolean executeCommand(String title, String[] args, StringBuffer response) { String command = makeCommand(title, args); try { VDMRecord responseObj = sendCommandResponse(command); boolean status = checkResponse(responseObj); response.append(responseObj.GetField(1).ToAscii()); return status; } catch (Exception e) { System.err.println("executeCommand: " + e.toString()); return false; }

TIVDM2Model Quality22 Constructing a Command Record private String makeCommand(String cmd, String[] args) { StringBuffer command = new StringBuffer(); command.append("mk_POP3Types`"); command.append(cmd); command.append("("); for (int index = 0; index < args.length; index++) { command.append(args[index]); if (index != args.length-1) command.append(","); } command.append(")"); return command.toString(); }

TIVDM2Model Quality23 Send Command Responses private VDMRecord sendCommandResponse(String command) { VDMRecord responseRecord = null; try { EvalCmd("debug " + channel + ".ClientSend(" + command + ")"); VDMFactory fact = app.GetVDMFactory(); VDMSequence args = fact.MkSequence(client); VDMGeneric response = interp.Apply(client,channel+ ".ClientListen", args); responseRecord = VDMRecordHelper.narrow(response); } catch (APIError e) { System.out.println("sendCommandResponse: " + e.msg.toString()); } return responseRecord; }

TIVDM2Model Quality24 Checking Responses private boolean checkResponse(VDMRecord response) { try { Log("response is " + response.ToAscii()); return response.GetTag().equals( "POP3Types`OkResponse"); } catch (APIError e) { System.err.println(e.toString()); return false; } }

TIVDM2Model Quality25 Interacting with Multiple Clients Two challenges: 1.The objects created by a client for a single POP3 session need to be unique for that client: otherwise it would be possible for one client to interfere with another client's session. 2.Only the very first client that registers with the tool set should load the specification and initialise the interpreter; otherwise a client's session could be prematurely terminated by another client reinitializing the interpreter in the middle of that session. 1 can be solved by: channel = "mc" + String.valueOf(client);

TIVDM2Model Quality26 Updating the Pop3ApiLayer Constructor public Pop3ApiLayer(JTextArea logArea) { try { this.logArea = logArea; ToolboxClient toolboxClient = new ToolboxClient(); app = toolboxClient. getVDMApplication(new String[]{}, ToolType.PP_TOOLBOX); client = app.Register(); channel = "mc" + String.valueOf(client); app.PushTag(client); interp = app.GetInterpreter(); if (!isInitialized()) { loadSpecification(); typeCheck(); initInterpreter(); } } catch (Exception e) { e.printStackTrace(System.err); System.err.println(e.toString()); } }

TIVDM2Model Quality27 isInitialized Definition private boolean isInitialized() throws APIError { VDMProject prj = app.GetProject(); ModuleListHolder moduleList = new ModuleListHolder(); prj.GetModules(moduleList); return moduleList.value.length != 0; }

TIVDM2Model Quality28 Summary What have I presented today? Assessing model quality Internal consistency External consistency What do you need to do now? Read chapter 13 Go on with your project to real-time inclusion Assess the models consistency If you know CORBA already you may use the API on your project Present your status to all of us

TIVDM2Model Quality29 Quote of the day Bertrand Meyer Formal specifications may become for software engineers what, say, differential equations are for engineers of other fields