CS551 - Lecture 6 1 CS551 Modelling with Objects (Chap. 3 of UML) Yugi Lee STB #555 (816) 235-5932

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

Database Systems: Design, Implementation, and Management Tenth Edition
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
OASIS Reference Model for Service Oriented Architecture 1.0
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Object-Oriented Analysis and Design
Introduction To System Analysis and Design
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Copyright W. Howden1 Lecture 13: Programming by Contract.
Software Testing and Quality Assurance
NJIT Use Case Model Operation Contracts Prepared By: Sumit Sharma.
Page 1 Building Reliable Component-based Systems Chapter 2 -Specification of Software Components Chapter 2 Specification of Software Components.
© 2005 Prentice Hall4-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
C++ Training Datascope Lawrence D’Antonio Lecture 11 UML.
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
חוזים – Contracts 1. Larman – Chapter 10 – SSDs 10.2 What are System Sequence Diagrams? (introduction) Use cases describe how external actors interact.
Chapter 6: The Traditional Approach to Requirements
System Analysis Overview Document functional requirements by creating models Two concepts help identify functional requirements in the traditional approach.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 06. Requirements.
An Introduction to Software Architecture
1 Catalysis Methodology Ali Khoshgozaran August 2002
Introduction To System Analysis and Design
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
1 Lecture 6: Operation Contracts. 2 Overview  What is contract ?  The guidelines for writing contracts for the system operations.  Use Case realizations.
Requirements as Usecases Capturing the REQUIREMENT ANALYSIS DESIGN IMPLEMENTATION TEST.
Requirements Capture. Four Steps of requirements capture List candidate requirements Understand system context Capture functional requirements Capture.
CS551 - Lecture 8 1 CS551 Modelling with Objects (Chap. 3 of UML) Yugi Lee STB #555 (816)
A Use Case Primer 1. The Benefits of Use Cases  Compared to traditional methods, use cases are easy to write and to read.  Use cases force the developers.
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.
TAL7011 – Lecture 4 UML for Architecture Modeling.
1 Capturing Requirements As Use Cases To be discussed –Artifacts created in the requirements workflow –Workers participating in the requirements workflow.
1 Capturing Requirements As Use Cases To be discussed –Artifacts created in the requirements workflow –Workers participating in the requirements workflow.
1 Version /05/2004 © 2004 Robert Oshana Requirements Engineering Use cases.
Design Model Lecture p6 T120B pavasario sem.
DOMAIN MODEL: ADDING ATTRIBUTES Identify attributes in a domain model. Distinguish between correct and incorrect attributes.
Software Requirements: A More Rigorous Look 1. Features and Use Cases at a High Level of Abstraction  Helps to better understand the main characteristics.
Formal Methods in Software Engineering1 Today’s Agenda  Quiz 2 next class  Presentation Schedule  Quick Review  Build Models Using OCL.
OMT Modeling 1. Object Model : presented by the object model and the data dictionary. 2. Dynamic Model: presented by the state diagrams and event flow.
Lecture 9-1 : Intro. to UML (Unified Modeling Language)
MDA & RM-ODP. Why? Warehouses, factories, and supply chains are examples of distributed systems that can be thought of in terms of objects They are all.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Session 3 How to Approach the UML Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 5, 2011 Presented by Kang-Pyo Lee.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
7-1 © Prentice Hall, 2007 Topic 7: Analysis Classes Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
UML - Development Process 1 Software Development Process Using UML.
CS223: Software Engineering
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Roles & Constraints These slides are licensed.
1 CEN 4020 Software Engineering PPT4: Requirement analysis.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
CS551 - Lecture 7 1 CS551 Interaction Models (Chapter 4 of UML) Yugi Lee STB #555 (816)
Business Processes A business process describes a set of activities that are necessary to complete a response to a stimulus applied to an organization.
1 Team Skill 3 Defining the System Part 1: Use Case Modeling Noureddine Abbadeni Al-Ain University of Science and Technology College of Engineering and.
Analysis Classes Unit 5.
Chapter 6 The Traditional Approach to Requirements.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Chapter 5 유스케이스 개요 Introduction to Use Cases
Dynamic Modeling of Banking System Case Study - II
Requirements: Use Case Models and Narratives
Slides by Steve Armstrong LeTourneau University Longview, TX
An Introduction to Software Architecture
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
ISpec: A Compositional Approach to Interface Specification
CS551 Behavior Models: Object Types and Operations (Chap. 3 of UML)
CS551 Behavior Models: Object Types and Operations (Chap. 3 of UML)
Presentation transcript:

CS551 - Lecture 6 1 CS551 Modelling with Objects (Chap. 3 of UML) Yugi Lee STB #555 (816)

2 CS551 - Lecture 6 Object Modelling Static model: the state of an object at any given moment (object attributes, relationships, constraints between objects) Dynamic model: the changes that happen to the state as event occur (actions affect objects, using the changes of objects and attributes in the object state) Interactive model: interactions between objects (the responsibility for achieving goal is divided among collaborating objects)

3 CS551 - Lecture 6

4 Dynamic Model: Object and Action The behavior of a type is specified by the actions it participates in. Each action is specified by actions spec(s). An action spec defines the effects of that action in terms of the attributes of the objects involved, and the conditions under which those effects hold, using: –preconditions: what is expected to be true at the start of the action –rely conditions: what is expected to be maintained true during the action –postconditions: what is correspondingly ensured to become true at the end of the action –guarantee conditions: what is ensured to remain true during the action

5 CS551 - Lecture 6 Action and Pre/Post Conditions action schedule_course (reqCourse: Course, reqStart: Date) pre: Provided there is an instructor qualified for this course who is free on this date, for the length of the course. post:A new confirmed session has been created, with course = reqCourse, startDate = reqStart, and endDate – startDate = reqCourse.length.

6 CS551 - Lecture 6

7 Dynamic Model: Action An action-occurrence may abstract a whole series of interactions and smaller changes. Action type: The set of action-occurrences that conform to a given action-spec. A particular action occurrence may belong to many action-types. Action spec: A specification of an action type. An action spec characterizes the effects of the occurrences on the states of the participating objects (with a postcondition).

8 CS551 - Lecture 6

9 Object and Action Object: anything that presents a definable encapsulated behavior to the world around it –individual programming-language objects, software components, programs, networks, relations, records, hardware, people, and organizations Action: specified by its effect on the state of the object and any information exchanged in the course of that action. –individual programming-language messages, procedure calls, complete dialogs between objects of all kinds. – the effects of an action even without knowing exactly who initiates it or how it works in detail.

10 CS551 - Lecture 6

11 CS551 - Lecture 6 Two Kind of Actions Localized Actions: operations –action Type::actionName (...)... –a one-sided specification of an action, focused entirely on a single object and how it responds to a request, without regard to the initiator of that request. Joint Actions: use-cases –action (party1: Type1, party2: Type2,...) :: actionName (...) –abstract multiple interactions and specific protocols for information exchange, –the net effect on all participants and the summary of information exchanged.

12 CS551 - Lecture 6 Dynamic Model: Action The postconditions and guarantee must hold for any action occurrence, provided its precondition and rely condition were met. The rely and guarantee conditions are less often utilized, and only for non-atomic actions with significant duration, which can happen concurrently with other actions. Order :: fulfill –pre: the order must be in the pending state –rely: while the order is being fulfilled the product specifications had better not change –post: the fulfilled order has been shipped to the customer based on the product specifications, and the order has been inserted into the billing queue –guarantee: true i.e. not particular rule maintained during an order's fulfillment.

13 CS551 - Lecture 6 More-Precise Action Specification Using snapshots to guide postconditions: informal --> snapshots --> formal –the action postconditions what to trying to determine –a snapshot illustrates only one case, a set of snapshots is needed, thinking tool. action assign_mentor (subject: Instructor, watchdog: Instructor) post: The watchdog is now the mentor of the subject. action assign_mentor (subject: Instructor, watchdog : Instructor) post -- the watchdog is now the mentor of the subject subject.mentor = watchdog

14 CS551 - Lecture 6 More-Precise Action Specification Comparing before and after: a postcondition makes an assertion about the states immediately before and after the action has happened. For every object there are two snapshots and two complete sets of attribute values to refer to. action assign_mentor (subject: Instructor, watchdog : Instructor) post subject.mentor = watchdog and let ex_mentee = in ex_mentee <> null ==> ex_mentee.mentor = null -- watchdog is now subject’s mentor, and if watchdog had a previous mentee, they now have none

15 CS551 - Lecture 6 More-Precise Action Specification Newly created objects: new action schedule_course (reqCourse: Course, reqStart: Date) post: let ns: Session.new [course = reqCourse and startDate = reqStart and endDate – startDate = reqCourse.length ] in endDate) Collections: set union (+) and set differnce (-) action reassign_course (session : Session, new_inst: Instructor) post: let ex_instructor = in ex_instructor.schedule = – session and new_inst.schedule = new_inst.schedule + session Summary: to avoid unnecessary details and simplify complexity by assuming a parameterized attribute whose values are available later

16 CS551 - Lecture 6 Two Java Implementations of a Calendar The internal representation and interactions differ widely between the implementations. Our behavior specification must abstract these irrelevant “internal” interactions and include only interactions with objects that the client should be aware of.

17 CS551 - Lecture 6 External Object Behavior Abstractions Internal Details

18 CS551 - Lecture 6 From Attributes to Operation Specification List the operations: addEvent, isFree, removeEvent, and calendarFor. Write informal operation descriptions of each one. Identify the inputs and outputs Working from your initial type diagram, sketch a pair of snapshots before and after each operation (draw them on one diagram) Draw a static type diagram of the object being specified, generalizing all snapshots.

19 CS551 - Lecture 6 From Attributes to Operation Specification Document the invariants that the model should satisfy. inv Event:: start <= end inv Instructor:: free(d: Date) = ( self.schedule [overlaps(d)] ->isEmpty ) inv Event:: overlaps(d: Date) = (start = d) Specify operations. Make the operation specs more precise; function is a side-effect free operation action Calendar::addEvent (d1: Date, d2: Date, i: Instructor, o: Object): Event pre: d1 forAll (d | i.free (d)) post: result: Event.new [ info = o & start = d1 & end = d2 & instructor = i & calendar = self] function Calendar::isFree (i: Instructor, d1: Date, d2: Date) : Boolean pre: d1 < d2 post: result = {d1..d2}->forAll (d | i.free (d))

20 CS551 - Lecture 6 From Attributes to Operation Specification Create parameter models. describe any input/output parameter types and their attributes and opertions to the extent that the client and the implementor need to understand and agree on them action Event::delete () pre: true post: -- the same effect as removing the event from the calendar [[ calendar.removeEvent (self) ]] Write a dictionary of terms and improve your informal specifications. –instructor the person assigned to a scheduled event –schedule the set of events instructor is currently scheduled for –free if an instructor is free on a date, no event on his schedule overlaps with that date Improve the model or design by some factoring.

21 CS551 - Lecture 6 Action with Invariants inv Instructor:: qualifiedFor -> includesAll (sessions.course) sessions ->forAll (s1, s2 | s <> s1 implies not s1.overlaps(s2)) inv Session:: confirmed ==> instructor <> null and end = start + course.duration action Scheduler::change_dates ( s: Session, d: Date ) pre:s.start > now and s.course <> nil and s.course.duration : Days post:s.start = d and s.end = d + course.duration after simplified action Scheduler::change_dates ( s: Session, d: Date ) pre:s.start > now post:s.start = d

22 CS551 - Lecture 6 Action with Invariants Static Invariants: hold before and after the actions in its range, required to be true of all the actions in its rage. Dynamic (effect) invariants: an effect that is invariant across all actions in its rage and is implicitly added to the postconditions of those actions.

23 CS551 - Lecture 6 Dynamic Invariants inv effect Calendar::count_invocations post: count += 1 An effect invariant is added to the postcondition of all actions in its range action Calendar::removeEvent (e: Event) pre : -- provided the event is on this calendar schedule->includes (e) post : -- that event has been removed from the calendar and instructor schedules not schedule->includes (e) and not (e) -- and the effect invariant is implicitly applied and count += 1

24 CS551 - Lecture 6 Admin Company schedule pay deliver Session date, topic cost Instructor qualified Students skills fee-due funds Captures important rules accurately without getting into implementation details Enable the Business User to raise and resolve critical issues early Static invariant Attribute constraint in all states Dynamic Invariant A state change rule that applies to all actions assigned Action Spec guarantees and assumptions of action Rules = Actions + Static + Dynamic Invariants “New session created, confirmed if qualified instructor available” “Any change in session must propagate to scheduler” “Assigned instructor is qualified for topic”

25 CS551 - Lecture 6 Context and Control of an Invariant Context: The type in which an invariant is written. Any object to conform to the type –the invariant should be always true. –the invariant can be broken behind the interface, but it must be restored when the operation is complete. Behind that interface are components of the design that have their own nested contexts and invariants that govern them