© Bennett, McRobb and Farmer 2002 1 Specifying Operations Based on Chapter 10 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design.

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

CS101: Introduction to Computer programming
Chapter 11 Describing Process Specifications and Structured Decisions
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
© 2010 Bennett, McRobb and Farmer1 Use Case Description Supplementary material to support Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
© 2010 Bennett, McRobb and Farmer1 Requirements Analysis 1: Requirements and Classes Based on Chapter 7 of Bennett, McRobb and Farmer: Object Oriented.
Chapter 4 Enterprise Modeling.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Process Specifications and Structured Decisions Systems Analysis and Design, 8e Kendall.
Introduction To System Analysis and Design
Software Testing and Quality Assurance
Systems Analysis and Design in a Changing World, Fourth Edition
Chapter 9 Describing Process Specifications and Structured Decisions
Chapter 9 Describing Process Specifications and Structured Decisions Systems Analysis and Design Kendall & Kendall Sixth Edition © 2005 Pearson Prentice.
Chapter 9 Describing Process Specifications and Structured Decisions
Software Testing and Quality Assurance
Detail Design Extending UML and Object Design. Object Design.
© 2005 Prentice Hall4-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
03/12/2001 © Bennett, McRobb and Farmer Object Interaction Based on Chapter 9 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
03/12/2001 © Bennett, McRobb and Farmer Activity Diagrams Based on Chapter 5 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and.
Kendall & KendallCopyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 9 Kendall & Kendall Systems Analysis and Design, 9e Process Specifications.
University of Toronto Department of Computer Science © Castro, Mylopoulos and Easterbrook Lecture 12: Modelling Business Rules & Processes Ü Review.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
03/12/2001 © Bennett, McRobb and Farmer What Is Object-Orientation? Based on Chapter 4 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
Object Specification Moving towards a more precise specification of software.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
03/12/2001 © Bennett, McRobb and Farmer Use Case Diagrams Based on Chapter 6 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and.
Chapter 3 Planning Your Solution
Kendall & KendallCopyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 9 Kendall & Kendall Systems Analysis and Design, 9e Process Specifications.
Chapter 7: The Object-Oriented Approach to Requirements
System Implementation System Implementation - Mr. Ahmad Al-Ghoul System Analysis and Design.
IS 320 Notes for Chapter 8. ClassX Problems: Low-Tech Fix Use last year's videos on ClassX  Select "Semesters" tab  Select IS 320  Select the week/lecture.
Chapter 9 Describing Process Specifications and Structured Decisions
Chapter 11 Describing Process Specifications and Structured Decisions Systems Analysis and Design Kendall and Kendall Fifth Edition.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Introduction To System Analysis and Design
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
© 2010 Bennett, McRobb and Farmer1 Specifying Operations Based on Chapter 10 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design.
WXGC6102: Object-Oriented Techniques Specifying Operations References: Chapter 10 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design.
Conceptual Modelling – Behaviour
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
9-1 © Prentice Hall, 2007 Chapter 9: Analysis Classes Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
1 A Student Guide to Object- Oriented Development Chapter 6 Identifying Functionality.
1 CSE323 การวิเคราะห์และออกแบบระบบ (Systems Analysis and Design) Lecture 07: Object Interaction and Specifying Operations.
© 2010 Bennett, McRobb and Farmer1 Requirements Analysis 2: Realizing Use Cases Based on Chapter 7 of Bennett, McRobb and Farmer: Object Oriented Systems.
The Software Development Process
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Systems Analysis and Design in a Changing World, Fourth Edition
7-1 © Prentice Hall, 2007 Topic 7: Analysis Classes Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Analysis Classes. What Is an Analysis Class?  A class that represents initial data and behavior requirements, and whose software and hardware-oriented.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Copyright © 2011 Pearson Education Process Specifications and Structured Decisions Systems Analysis and Design, 8e Kendall & Kendall Global Edition 9.
7 Systems Analysis – ITEC 3155 The Object Oriented Approach – Use Cases.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11b: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
1 Object Oriented Analysis and Design System Events & Contracts.
Systems Analysis and Design in a Changing World, Fourth Edition
Analysis Classes Unit 5.
Algorithm and Ambiguity
Programming Languages 2nd edition Tucker and Noonan
Understanding Problems and how to Solve them by using Computers
Chapter 11 Describing Process Specifications and Structured Decisions
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

© Bennett, McRobb and Farmer Specifying Operations Based on Chapter 10 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design Using UML, (2 nd Edition), McGraw Hill, 2002.

© Bennett, McRobb and Farmer In This Lecture You Will Learn: n About the role of operation specifications n What is meant by “Contracts” n About algorithmic and non-algorithmic techniques, and how they differ n How to use: –Decision Tables –Pre- and Post-condition Pairs –Structured English –Activity Diagrams –Object Constraint Language

© Bennett, McRobb and Farmer Why We Specify Operations n From analysis perspective: –Ensure users’ needs are understood n From design perspective: –Guide programmer to an appropriate implementation (i.e. method) n From test perspective: –Verify that the method does what was originally intended

© Bennett, McRobb and Farmer Types of Operation and Their Effects n Operations with side-effects may: –Create or destroy object instances –Set attribute values –Form or break links with other objects –Carry out calculations –Send messages or events to other objects –Any combination of these n Operations without side-effects are pure queries –Request data but do not change anything

© Bennett, McRobb and Farmer Services Among Objects n When objects collaborate, one object typically provides a service to another n Examples: –A Client object might ask a Campaign object for its details –The same Client object might then ask a boundary object to display its related Campaign details to the user

© Bennett, McRobb and Farmer Contracts: an Approach to Defining Services n A service can be defined as a contract between the participating objects n Contracts focus on inputs and outputs n Intervening process is seen as a black box n Irrelevant details are hidden n This emphasizes service delivery, and ignores implementation

© Bennett, McRobb and Farmer Contract-Style Operation Specification n Intent or purpose of the operation n Operation signature, including return type n Description of the logic n Other operations called n Events transmitted to other objects n Any attributes set n Response to exceptions (e.g. an invalid parameter) n Non-functional requirements (adapted from Larman, 1998 and Allen and Frost, 1998)

© Bennett, McRobb and Farmer Types of Logic Specification n Logic description is probably the most important element n Two main categories: n Algorithmic types are white box—they focus on how the operation might work n Non-algorithmic types are black box— they focus on what the operation should achieve

© Bennett, McRobb and Farmer Non-Algorithmic Techniques n Appropriate where correct result matters more than method to arrive at it n Decision tree: complex decisions, multiple criteria and steps (not described further here) n Decision table: similar applications to decision tree n Pre- and Post-condition pairs: suitable where precise logic is unimportant or uncertain

© Bennett, McRobb and Farmer Conditions and actionsRule 1Rule 2 Rule 3 Conditions Is budget likely to be overspent?NYY Is overspend likely to exceed 2%?-NY Actions No actionX Send letter XX Set up meeting X Example Decision Table

© Bennett, McRobb and Farmer Pre- and Post-condition Pair pre-conditions: creativeStaffObject is valid gradeObject is valid gradeChangeDate is a valid date post-conditions: a new staffGradeObject exists new staffGradeObject linked to creativeStaffObject new staffGradeObject linked to previous value of previous staffGradeObject. gradeFinishDate set equal to gradeChangeDate

© Bennett, McRobb and Farmer Algorithmic Techniques n Suitable where users understand the procedure for arriving at a result n Can be constructed top-down, to handle arbitrarily complex functionality n Examples: –Structured English –Activity Diagrams

© Bennett, McRobb and Farmer Structured English n Commonly used, easy to learn n Three types of control structure, derived from structured programming: –Sequences of instructions –Selection of alternative instructions (or groups of instructions) –Iteration (repetition) of instructions (or groups of instructions)

© Bennett, McRobb and Farmer Sequence in Structured English n Each instruction executed in turn, one after another get client contact name sale cost = item cost * ( 1 - discount rate ) calculate total bonus description = new description

© Bennett, McRobb and Farmer Selection in Structured English n One or other alternative course is followed, depending on result of a test: if client contact is ’Sushila’ set discount rate to 5% else set discount rate to 2% end if

© Bennett, McRobb and Farmer Iteration in Structured English n Instruction or block of instructions is repeated –Can be a set number of repeats –Or until some test is satisfied, for example: do while there are more staff in the list calculate staff bonus store bonus amount end do

© Bennett, McRobb and Farmer Activity Diagrams n Are part of UML notation set n Can be used for operation logic specification, among many other uses n Are easy to learn and understand n Have the immediacy of graphical notation n Bear some resemblance to old- fashioned flowchart technique

© Bennett, McRobb and Farmer Link to CreativeStaff Create new StaffGrade Link to previous StaffGrade Set previous StaffGrade gradeFinishDate Simple Activity Diagram

© Bennett, McRobb and Farmer Check approval for grade change [approved by Director] [not approved by Director] Print approval request Link to CreativeStaff Create new StaffGrade Link to previous StaffGrade Set previous StaffGrade gradeFinishDate Activity Diagram with Selection

© Bennett, McRobb and Farmer Calculate bonus [bonus > £250] Add to list [more StaffMembers] Format list [no more StaffMembers] Add to ‘star’ list Create warning letter [bonus < £25] [bonus >= £25 AND bonus <= £250] Activity Diagram with Selection and Iteration

© Bennett, McRobb and Farmer Object Constraint Language n Most OCL statements consist of: –Context, Property and Operation n Context –Defines domain within which expression is valid –Instance of a type, e.g. object in class diagram –Link (association instance) may be a context n A property of that instance –Often an attribute, association-end or query operation

© Bennett, McRobb and Farmer n OCL operation is applied to the property n Operations include –Arithmetical operators *, +, - and / –Set operators such as size, isEmpty and select –Type operators such as oclIsTypeOf

© Bennett, McRobb and Farmer OCL expressionInterpretation Person self.gender In the context of a specific person, the value of the property ‘gender’ of that person — i.e. a person’s gender. Person self.savings >= 500 The property ‘savings’ of the person under consideration must be greater than or equal to 500. Person self.husband->notEmpty implies self.husband.gender = male If the set ‘husband’ associated with a person is not empty, then the value of the property ‘gender’ of the husband must be male. Boldface denotes OCL keyword, but has no semantic import. Company self.CEO->size <= 1 The size of the set of the property ‘CEO’ of a company must be less than or equal to 1. That is, a company cannot have more than 1 Chief Executive Officer. Company self.employee->select (age < 60) The set of employees of a company whose age is less than 60.

© Bennett, McRobb and Farmer OCL Used for Pre- and Post-conditions context CreativeStaff::changeGrade (grade:Grade, gradeChangeDate:Date) pre: grade oclIsTypeOf(Grade) gradeChangeDate >= today post: self.staffGrade[grade]->exists self.staffGrade[previous]->notEmpty self.staffGrade.gradeStartDate = gradeChangeDate self.staffGrade.previous.gradeFinishDate = gradeChangeDate

© Bennett, McRobb and Farmer Summary In this lecture you have learned about: n The role of operation specifications n What is meant by “Contracts” n Algorithmic and non-algorithmic techniques, and how they differ n How to use: –Decision Tables, Pre- and Post-condition Pairs, Structured English, Activity Diagrams and Object Constraint Language

© Bennett, McRobb and Farmer References n Bennett, McRobb and Farmer (2002) n Yourdon (1989) covers Structured English and Pre- and Post-conditions well n Senn (1989) is good on Decision Tables n Larman (1998) takes a contract-based approach to O-O analysis and design, with examples taken to Java code (For full bibliographic details, see Bennett, McRobb and Farmer)