Chapter 11 Following the Trail; Examining Execution Sequences

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

System Sequence Diagrams
Actors and use cases Use-case diagram Brief notation Prioritization Fully dressed notation Requirements Functional requirements  Use-cases.
Jan 15, Ron McFadyen1 Ch 9. Use-case model: drawing System Sequence Diagrams Iteration: a simple cash-only success scenario of Process Sale.
Interaction Diagrams Activity Diagram State Machine Diagram
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
January Ron McFadyen1 Ch 9. Use-case model: drawing System Sequence Diagrams Elaboration Iteration 1: a simple cash-only success scenario of.
Lecture 4 Class Responsibility Collaboration Cards
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Object Oriented Analysis Process
Object-Oriented Analysis and Design
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
1 Lab Beginning Analysis and Design 4 Completion of first version of use case diagram initiates the processes of analysis and design. 4 UML provides.
User Interface Theory & Design
Copyright CovalentWorks Training Guide for Invoices MYB2B Powered by CovalentWorks.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
BTS330 Documenting Use Cases.
Introduction to Sequence Diagrams
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
High-Level Design With Sequence Diagrams COMP314 (based on original slides by Mark Hall)
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
1 Object-Oriented Analysis Use Case Driven. 2 The outline method for OOA 1.Identify object classes within the problem domain 2.Define the behaviour of.
Faculty of Computer & Information Software Engineering Third year
Access Online Cardholder Transaction Approval Training 1 Client Logo.
1 Object-Oriented Modeling Using UML CS 3331 Section 2.4 Modeling Requirements with Use Cases.
User Interface Theory & Design Lecture 6a 1.  User interface is everything the end user comes into contact with while using the system  To the user,
1 A Student Guide to Object- Oriented Development Chapter 6 Identifying Functionality.
SYS466: Analysis and Design Using OO Models Domain Class Diagram.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
Information Systems Engineering Interaction Diagrams: Sequence Diagram Collbortion Diagram.
Interaction Diagrams Interaction Diagrams allow the designer to show how groups of objects collaborate in some behavior. –Interaction Diagrams will show.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
1 Examining Execution Sequences Introducing Sequence Diagrams.
1 Class responsibilities & relationships. 2 Responsibilities Responsibilities describe a class’s purpose in terms of its functionality Responsibilities.
CSCI-383 Object-Oriented Programming & Design Lecture 12.
Scenario A scenario is a sequence of steps describing an interaction between a user and a system. Use case is a set of scenarios tied together by a common.
111 Subsystems CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 7)
CSC 480 Software Engineering PSP Project 2 August 27, 2004.
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
IBC top tips Geoff Thompson Transitional Finance Officer Education Financial Services.
3M Partners and Suppliers Click to edit Master title style USER GUIDE Supplier eInvoicing USER GUIDE The 3M beX environment: Day-to-day use.
Invoices and Service Invoices Training Presentation for Raytheon Supply Chain Platform (RSCP) April 2016.
, , Devloped By Deep Solutions.
1 8.1 Requirements Analysis Rules of Thumb Rules of Thumb Models should focus on requirements that are visible within the problem or business domain. The.
SchoolSuccess for Coordinators
An informal, team oriented, OO design system
Procurement Desktop Defense (PD²) Creating an Indefinite Delivery Contract SPS Spotlight Series February 2014.
eInvoice Business Process
GRASP – Designing Objects with Responsibilities
ATM OO Design and Implementation Case Study
Chapter 12: Collaboration Diagram - PART2
Dynamic Modeling of Banking System Case Study - I
Object-Oriented Systems Analysis and Design Using UML
Collaborations and Hierarchies
Behavioral Modeling.
Binghamton University Business System Purchase Requisitions
Recommended Budget Reductions
The Fulfillment Process
Use Case Modeling - techniques for detailing use cases
CRC: Classes, Responsibilities, and Collaborations
Chapter 3 The DATA DIVISION.
SAD ::: Spring 2018 Sabbir Muhammad Saleh
Week 12: Activity & Sequence Diagrams
Exploring the Power of EPDM Tasks - Working with and Developing Tasks in EPDM By: Marc Young XLM Solutions
Chapter 10 Object States and The Statechart Diagram
Interaction diagrams Interaction diagrams are models that describe how groups of objects collaborate in some behavior. Typically, an interaction diagram.
Using Use Case Diagrams
Chapter 5.
Use Case Analysis – continued
Object Oriented System Design Responsibilities
Presentation transcript:

Chapter 11 Following the Trail; Examining Execution Sequences

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.4. CRC Cards 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.4. CRC Cards 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams

Responsibility-Driven Design (RDD) Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. Responsibility-Driven Design (RDD) Takes a real-world view of objects and classes. The purpose of having an object with data is so that it can do something for us. So it has a Responsibility to do what we need, that is, to provide a Service to us or some other object, possibly a User object.

to provide that service when requested Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. Wherever a service exists, we can say there is a Responsibility to provide that service when requested to those who need it.

“Responsibilities include two key items: Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. “Responsibilities include two key items: The knowledge that an object maintains (i.e., the data it carries), And the actions an object can perform (i.e., its behaviors.)” Rebecca Wirfs-Brock et al. (1990)

The knowledge (data) implies: Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. The knowledge (data) implies: a group of responsibilities to provide the attribute values to an Actor, i.e., to any (qualified) person who asks. Some Actors will simply request values, others will update values, or create or delete Instances.

The actions (behaviors) each imply Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. The actions (behaviors) each imply a Responsibility to do something, e.g.: An Invoice has a responsibility to print itself, And to update its Total attribute, Calculate and print its Tax and Grand Total. A Line Item has a responsibility to calculate and return its Extended Price, And to print itself.

The Invoice has a responsibility to Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. The Invoice has a responsibility to ensure that the Account Balance is updated. This responsibility it then delegates to the Account object. The Account object has a responsibility to update its Balance attribute.

between the two classes of objects. Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities. In this scenario, The invoice has no responsibility to advise the Customer when it has been printed, But it must notify the User if it can not complete its assigned task. In this sense we can say that there is an Agreement, or a Contract between the two classes of objects.

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.3. Collaborations 11.4. CRC Cards 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams 11.2. Contracts

Chapter 11: Responsibilities and Collaborations 11.2. Contracts. The “agreement” between two classes is such that: When, say, a Customer object sends a message, The chosen Invoice object will provide a service by printing itself.

Chapter 11: Responsibilities and Collaborations 11.2. Contracts. Webster defines a contract as: “A binding agreement between two or more persons or parties.” Wirfs-Brock et al (1990) describe a contract as: “ A list of services an instance of one class can request from an instance of another.”

Chapter 11: Responsibilities and Collaborations 11.2. Contracts. Note this is a Client-Server relationship, Where the client requests a service, From the Server object, and expects that it will be done. But sometimes the server needs help to do its task . . .

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.4. CRC Cards 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams 11.3. Collaborations

Chapter 11: Responsibilities and Collaborations 11.3. Collaborations. In the last scenario, The Invoice was unable to do the job alone, And had to ask for help From the Line Item and Account classes. It delegated the updating to the Account class, And multiplying Quantity by Unit Price to the Line Item class.

Chapter 11: Responsibilities and Collaborations 11.3. Collaborations. Often a service needed by a client Requires data that the server doesn’t have, Or tasks that the server doesn’t know how to do, So the server calls on other classes for help. Object #1 #2 Request for service Response Client Server It starts like this:

Chapter 11: Responsibilities and Collaborations 11.3. Collaborations. Then the server asks for help: Object #1 #2 Request for service Response Client Server #3 Request for assistance Help response Note that for this request, the server is now a client.

Chapter 11: Responsibilities and Collaborations 11.3. Collaborations. This we call a collaboration, A request from a client to a server, for a service that will help the client fulfil one of its own responsibilities.

Chapter 11: Responsibilities and Collaborations 11.3. Collaborations. Wirfs-Brock has endorsed and promoted a handy tool for finding Responsibilities and Collaborations . . .

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams 11.4. CRC Cards

There is one card per class. Write the class details at the top. Chapter 11: Responsibilities and Collaborations 11.4. Class Cards (CRC Cards). There is one card per class. Write the class details at the top. The left column is for the responsibilities, The right column is for the collaborating classes (or the method in the collaborating class.)

Here is a CRC Card for a Library Book: Chapter 11: Responsibilities and Collaborations 11.4. Class Cards (CRC Cards). Class: Identifier Book Book No. Responsibilities Collaborations Know Book No. Know Title Know Author Know Date Published Know Date Purchased Know Purchase Price Know Depreciated Value Know Date Last Out Know Date Last In Know Date last Shelved Here is a CRC Card for a Library Book: SignBookOut Subscriber Sign-Out CheckBookIn Sign-Out ShelveBook

Chapter 11: Responsibilities and Collaborations 11. 4 Chapter 11: Responsibilities and Collaborations 11.4. Class Cards (CRC Cards). Know Invoice no. Know Customer No. Class: Identifier Responsibilities Collaborations Invoice Invoice No. Know Invoice No. Know Customer No. Print Invoice Calculate Invoice Total Line Item Class: Identifier Line Item Invoice No. + Line No. Responsibilities Collaborations Know Invoice No. Know Line No. Know Product Code Know Quantity Sold Know Unit of Measure Know Actual Unit Price CalculateExtendedPrice PrintLineItem Product Tax Rate The Invoice Example

Chapter 11: Responsibilities and Collaborations 11. 4 Chapter 11: Responsibilities and Collaborations 11.4. Class Cards (CRC Cards). Class: Identifier Invoice Invoice No. Receivables Account Account No. Responsibilities Collaborations Know Invoice no. Know Customer No. Know Account No. Know Customer No. Know Description Know Balance Know Balance 30 Days Know Balance 60 Days Know Balance 90 Days Identifier Responsibilities Collaborations Class: Receivables Transaction Transaction No. Know Account No. Know Transaction No. Know Date Know Cash Amount PostToAccount PrintStatementLine Print Statement AddTransactionToBalance Receivables Transaction The Invoice Example

So for now we are . . . Finding names for the behaviors. Chapter 11: Responsibilities and Collaborations 11.4. Class Cards (CRC Cards). To fill in the cards, there are a number of ideas Wirfs-Brock recommends for finding and naming Responsibilities Remember, at Analysis that’s our goal: Finding names for the behaviors. Later, at design time, we will spec them out in detail. So for now we are . . .

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.4. CRC Cards 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams 11.5. Identifying Responsibilities

First, enter all the “Know” responsibilities. Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. First, enter all the “Know” responsibilities. Basically, each attribute must have: An Update responsibility, and A Provide-the-value-to-those-who-need-it For these, we may wish to group attributes in related clusters. Then enter any other behaviors that we’re already aware of.

Use Case Scenarios Walk-through the system, Using the Use Cases. Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. Use Case Scenarios Walk-through the system, Using the Use Cases. As Actors (users) walk through each Use Case, Note which class is being queried or updated at each step of the procedure. Then check if an appropriate responsibility has already been identified, And if not then add it.

Chapter 11: Responsibilities and Collaborations 11. 5 Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. Input/Output Data transfers require at least Update and Provide responsibilities, and often Validate as well, and Report Errors. Output: Provide Data and Format, Calculations, Graphics, etc.

Chapter 11: Responsibilities and Collaborations 11. 5 Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. User Interactions To get even more value from the Use cases, Bring in additional users to do more walk-thrus. Watch especially for “what-ifs” that may not have been noticed earlier.

Prompts and Error Messages Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. Prompts and Error Messages We may already be aware of some from our earlier work. Each prompt represents input, So some class has a Receive responsibility. Each Error message represents a responsibility to test for some condition, And to report on it.

Instance Creation and Deletion Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. Instance Creation and Deletion Every class has a responsibility to crate instances of itself, And may need more than one way to do it (i.e., several «create» methods). Every class has a responsibility to delete or archive unwanted instances. Others may go into a “suspense” state while awaiting final archiving or deletion

all the responsibilities, there is a check to do Chapter 11: Responsibilities and Collaborations 11.5. Identifying Responsibilities. Once we find all the responsibilities, there is a check to do to ensure that each one is in the appropriate class . . .

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.4. CRC Cards 11.5. Identifying Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams 11.6. Assigning Responsibilities

For most responsibilities it’s obvious Chapter 11: Responsibilities and Collaborations 11.6. Assigning Responsibilities. For most responsibilities it’s obvious which class they belong in. Normalization requires data be grouped by the class it describes, and encapsulation requires that the code to manipulate it be in the same class.

Wirfs-Brock’s Power Principle Chapter 11: Responsibilities and Collaborations 11.6. Assigning Responsibilities. Wirfs-Brock’s Power Principle If all the “power” and “intelligence” in a system Is in just a few classes, They become unwieldy, And re-useability is reduced. So we may need to: Split a class into two or more, or Re-assign some responsibilities to other classes.

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.4. CRC Cards 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.8. Sequence Diagrams 11.7. Identifying Collaborations

These questions must be asked about each Chapter 11: Responsibilities and Collaborations 11.7. Identifying Collaborations. These questions must be asked about each responsibility we have discovered: Does this class have everything it needs to do this? If not, what is missing? What data is missing? What additional tasks are needed before, during, or after the main task?

What classes in the model can supply these? Chapter 11: Responsibilities and Collaborations 11.7. Identifying Collaborations. What classes in the model can supply these? Can any of them? If so, record the collaboration. If not, then Add an attribute or responsibility, or Define a new class, or Browse available class libraries.

Follow the chain to its end right now while the trail is still warm Chapter 11: Responsibilities and Collaborations 11.7. Identifying Collaborations. Sometimes a client responsibility Requires help from a contracting server, Who needs a “subcontractor” Who needs another one, and so on. When this happens, Follow the chain to its end right now while the trail is still warm

Then we approach it from the other view: Chapter 11: Responsibilities and Collaborations 11.7. Identifying Collaborations. Then we approach it from the other view: What significant data does this class carry? What important things can it do? Who needs it? What other classes might need the data require the services of this class.

Chapter 11: Responsibilities and Collaborations 11.1. Objects and Responsibilities 11.2. Contracts 11.3. Collaborations 11.4. CRC Cards 11.5. Identifying Responsibilities 11.6. Assigning Responsibilities 11.7. Identifying Collaborations 11.8. Sequence Diagrams

from the point of view of Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams A CRC Card: Documents the interactions among objects i.e., the method calls and data transfers from the point of view of one class at a time

Shows the complete pattern of method calls and collaborations Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams A CRC Card: Shows the complete pattern of method calls and collaborations for that class

Society of Objects A Sequence Diagram: Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams On the other hand, A Sequence Diagram: Documents those same interactions, showing the pattern of calls among a Society of Objects (i.e., a bunch of objects that regularly hold conversations)

Begin by following a use case Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams Begin by following a use case Follow our CRC cards Update cards where needed At the same time map the steps on a sequence diagram . . .

Objects are shown along the top. Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams :Window :Position Steve:Manager Old:Occupancy Joe: Objects are shown along the top. Use a class name Or an instance name Or both. The colon ( : ) comes after the instance name and before the class name

t The vertical axis is Time Shown as dashed lines, and reading down Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams :Window :Position Old:Occupancy Steve:Manager Joe: t The vertical axis is Time Shown as dashed lines, and reading down Each vertical Time axis is called a Lifeline

Chapter 11: Responsibilities and Collaborations 11. 8 Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams :Window :Position Old:Occupancy Steve:Manager Joe: t We place a skinny box on each lifeline This is called a focus of control or an activation line It shows what part of its life the object is active

A dashed arrow indicates the response Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams :Window :Position Old:Occupancy Steve:Manager Joe: displayPosName(posNo) archiveOldOccupancy(date) To begin handling a “Promotion”, a screen object queries a Position instance. A dashed arrow indicates the response Then the screen object sends a message to archive the old position occupancy data, with today’s date as parameter

Chapter 11: Responsibilities and Collaborations 11. 8 Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams :Window :Position Old:Occupancy Steve:Manager Joe: displayPosName(posNo) New: Occupancy archiveOldOccupancy(date) « create » success() advise() Then we send a message to « create » a new Occupancy instance Then a pair of unanswered messages to advise the Manager and Employee instances These ones are asynchronous Signals.

Summary: So we work through our use case Using our CRC cards Chapter 11: Responsibilities and Collaborations 11.8. Sequence Diagrams Summary: So we work through our use case Using our CRC cards Drawing a Sequence Diagram as we go And adding to the CRC cards as needed.

End of Chapter 11