Object Interaction. Object Diagrams. Object Diagrams Object



Similar documents
III. Class and Object Diagrams

III. Class and Object Diagrams

Génie Logiciel et Gestion de Projets. Software Requirements Engineering

Lectures 2 & 3: Introduction to Modeling & UML. Getting started

Sequence Diagram Tutorial. From: UML Distilled, Third Edition, Chapter 4 M. Fowler

Sequence Diagrams. Massimo Felici. Massimo Felici Sequence Diagrams c

TDDC88 Lab 2 Unified Modeling Language (UML)

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

In this Lecture you will Learn: Systems Development Methodologies. Why Methodology? Why Methodology?

Object-oriented design methodologies

Object Oriented Programming. Risk Management

Use Cases. Use Cases Diagrams

Designing Real-Time and Embedded Systems with the COMET/UML method

UML SUPPORTED SOFTWARE DESIGN

II. Conceptual Modeling

SOFTWARE PROCESS MODELS

3C05: Unified Software Development Process

Basic Unified Process: A Process for Small and Agile Projects

IRA 423/08. Designing the SRT control software: Notes to the UML schemes. Andrea Orlati 1 Simona Righini 2

PROJECT MANAGEMENT METHODOLOGY OF OBJECT- ORIENTED SOFTWARE DEVELOPMENT

Unit I Page No. 1 System Development Object Basics Development Life Cycle Methodologies Patterns Frameworks Unified Approach UML

Aspect Oriented Strategy to model the Examination Management Systems

A UML Introduction Tutorial

[1] [2]

Design and UML Class Diagrams. Suggested reading: Practical UML: A hands on introduction for developers

Use Case Diagrams. Tutorial

Software Requirements Specification of A University Class Scheduler

DEVELOPING REQUIREMENTS FOR DATA WAREHOUSE SYSTEMS WITH USE CASES

Using UML Part Two Behavioral Modeling Diagrams

Evaluation of a Use-Case-Driven Requirements Analysis Tool Employing Web UI Prototype Generation

Masters of Science in Software & Information Systems

UML: Unified Modeling Language

How To Draw A Cell Phone Into A Cellphone In Unminimal Diagram (Uml)

I219 Software Design Methodology

(BA122) Software Engineer s Workshop (SEW)

Software Development: An Introduction

Object Oriented Design

Software Design Models, Tools & Processes *

Analysis and Design with UML

Execution of A Requirement Model in Software Development

Dynamics CRM for Outlook Basics

Use Cases. Reference: Craig Larman, Applying UML and Patterns, Ch. 6

Communication Diagrams

CHAPTER_3 SOFTWARE ENGINEERING (PROCESS MODELS)

2. Analysis, Design and Implementation

A comparison of BON and Hodge-Mock. oriented software development methodologies

Universiti Teknologi MARA. Requirement Analysis Using UML Approach for Research Management System (RMS)

Introduction. UML = Unified Modeling Language It is a standardized visual modeling language.

Applying 4+1 View Architecture with UML 2. White Paper

Information Systems Analysis and Design CSC John Mylopoulos. Software Architectures Information Systems Analysis and Design CSC340

Object Oriented Analysis and Design and Software Development Process Phases

Types of UML Diagram. UML Diagrams OOAD. Computer Engineering Sem -IV

Course Registration Case Study

Use Cases and Scenarios

Exercise 8: SRS - Student Registration System

IV. Software Lifecycles

Towards an Integration of Business Process Modeling and Object-Oriented Software Development

MODERN OBJECT-ORIENTED SOFTWARE DEVELOPMENT

How to make a good Software Requirement Specification(SRS)

Modeling a Problem Scenario with UML

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Object-Oriented Design Guidelines

Using Use Cases for requirements capture. Pete McBreen McBreen.Consulting

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Use-Case Analysis. ! What is it? ! From where did it come? ! Now part of UML

Menouer Boubekeur, Gregory Provan

Title: Topic 3 Software process models (Topic03 Slide 1).

11 November

Contents. Introduction and System Engineering 1. Introduction 2. Software Process and Methodology 16. System Engineering 53

UML Tutorial: Sequence Diagrams.

DISCLAIMER OVERVIEW WHY DO WE MODEL WHAT IS QUALITY? Jeff Jacobs,

Understanding Data Flow Diagrams Donald S. Le Vie, Jr.

Mapping from Business Processes to Requirements Specification

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:

ATM Case Study OBJECTIVES Pearson Education, Inc. All rights reserved Pearson Education, Inc. All rights reserved.

The Unified Software Development Process

Assuming the Role of Systems Analyst & Analysis Alternatives

Security Contact User Guide

Process Modeling Notations and Workflow Patterns

Table of Contents Author s Preface... 3 Table of Contents... 5 Introduction... 6 Step 1: Define Activities... 7 Identify deliverables and decompose

Detecting Defects in Object-Oriented Designs: Using Reading Techniques to Increase Software Quality

State of Practice in Modeling and Model-Driven Development

Tool Support for Software Variability Management and Product Derivation in Software Product Lines

Get Started. Log in to PowerSchool Parent Portal. PowerSchool Parent Portal Start Page

ISSUES OF STRUCTURED VS. OBJECT-ORIENTED METHODOLOGY OF SYSTEMS ANALYSIS AND DESIGN

SysML Modelling Language explained

Semantic Object Language Whitepaper Jason Wells Semantic Research Inc.

This document is provided "as-is". Information and views expressed in this document, including URLs and other Internet Web site references, may

Instructional Design Framework CSE: Unit 1 Lesson 1

Announcements. SE 1: Software Requirements Specification and Analysis. Review: Use Case Descriptions

Appendix... B. The Object Constraint

A UML Documentation for an Elevator System. Distributed Embedded Systems, Fall 2000 PhD Project Report

Modeling the User Interface of Web Applications with UML

In this Lecture you will Learn: Development Process. Unified Software Development Process. Best Practice

A HW/SW Codesign Methodology based on UML

UML basics: An introduction to the Unified Modeling Language

Software Project Management and UML

Transcription:

Object Interaction Object Diagrams Object collaboration using CRC cards Object collaboration using a Sequence Diagram Object collaboration using a Collaboration diagram How to cross-check check between Interaction/Collaboration diagrams and a Class Diagram Object Interaction -- 1 Object Diagrams Model the instances of things contained in class diagrams. Show a set of objects and their relationships at a point in time. Used to model a snapshot of the system at a moment in time and rendering a set of objects, their state, and their relationships. Freeze a moment in time. Object Interaction -- 2 Page 1

Simple Objects : Course Bill Clinton courseno: csc340" description: OOAD" Jaelson: instructor : student Monica: student someone : Object Interaction -- 3 Multiobjects Multiobjects: set of objects, with undefined number of elements p2: Instructorr c1: Course c3: Course c2: Course : Student : Student Multiobjects Object Interaction -- 4 Page 2

Communication and Collaboration between Objects Fundamental to OO Which object should be responsible for each part of the overall behavior? Allocating operations to appropriate classes. Atribute X Complex tasks What collaborations between objects are required to generate the overall application functionality? Identifying what messages should be sent between objects and the conditions under which they should be sent. Object Interaction -- 5 Object Interaction and Collaboration Objects only contain data and methods which are relevant to their own responsibilities They don t know about other objects data. To get the kind of functionality which is required for a system to work, the objects have to work together collaborate Objects collaborate by sending messages to one another calling operations of the required instance Objects can only send messages to one another if there is an association between them Therefore, there must be an association between their classes Object Interaction -- 6 Page 3

Responsibilities One way of viewing the problem of assigning operations is in terms of the responsibilities of the objects. A responsibility is high level description of something a class can do. Reflects the knowledge or information that is available to that class, either stored within its own attribute or requested via collaboration with other classes. Object Interaction -- 7 Responsibilities The aim of OO-Analysis-and-Design is to distribute system functionality evenly among its classes Not that all classes have exactly equal levels of responsibilities, but rather that each class should have appropriate responsibility When responsibilities are evenly distributed, each class tends not to be unduly complex Easier to develop, to test and maintain Resilient to change in its requirements A class that it relatively small and self-contained has much greater potential for reuse Object Interaction -- 8 Page 4

CRC (Class Responsibility Collaboration) Cards One way to assign operations to objects is to work with CRC Cards to determine the responsibilities of each object. CRC stands for: Class Responsibility Collaboration CRC can be used at several different stages of project, for different purposes Here we use it in modeling object interaction Object Interaction -- 9 CRC Cards These are cards which for each class show what its responsibilities are, in terms of its attributes the operations it can carry out the names of the other classes it needs to collaborate with in order to carry out its responsibilities Object Interaction -- 10 Page 5

Role Play with CRC Cards In analysis we can spend time role playing with CRC cards to try to sort out the responsibilities of objects and to determine which are the other objects they need to collaborate with in order to carry out those responsibilities Often the responsibilities start out being vague and not as precise as the operations which may only become clear as we move into design. Sometimes we need to role play the objects in the system and test out the interactions between them. Object Interaction -- 11 I m a Campaign... I m a Campaign. I know my title, start date, finish date and how much I am estimated to cost. When I ve been completed, I know how much I actually cost and when I was completed. I can calculate the difference between my actual and estimated costs. When I ve been paid for, I know when the payment was made. I can calculate the contribution made to me by each member of staff who worked on me. Object Interaction -- 12 Page 6

I m a CreativeStaff... I m a CreativeStaff. I know my staff no, name, start date and qualification. I can calculate how much bonus I am entitled to at the end of the year. Does it make sense to include I can calculate the contribution made to each campaign I have worked on by each member of staff who worked on it. or does that belong in Campaign? Object Interaction -- 13 Class: Campaign Responsibilities: Title StartDate FinishDate EstimatedCost ActualCost CompletionDate DatePaid AssignManager RecordPayment Completed GetCampaignContribution CostDifference Collaborating Classes CreativeStaff Object Interaction -- 14 Page 7

Class: CreativeStaff Responsibilities: StaffNo StaffName StaffStartDate Qualification Collaborating Classes CalculateBonus ChangeGrade Campaign StaffGrade Grade Object Interaction -- 15 Sequence Diagrams CRC cards and role playing may help to find out what the responsibilities of objects are and which other objects they need to collaborate with, but They do not provide a way of documenting these interactions for a particular Use Case -> Sequence Diagrams An interaction is a behavior that comprises a set of messages exchanged among a set of objects within a context to accomplish a purpose. A message is a specification of a communication between objects that conveys information with the expectation that activity will ensue. Message types: sync, async, time-out, uncommitted, etc. Object Interaction -- 16 Page 8

Sequence Diagrams There will be a Sequence Diagram (SD!) for each Use Case in the system. We draw SDs in order to document how objects collaborate to produce the functionality of each use case. The SDs show the data and messages which pass across the system boundary and the messages being sent from one object to another in order to achieve the overall functionality of the Use Case Object Interaction -- 17 Sequence Diagrams A Sequence Diagram can be seen as an expansion of a use case to the lowest possible level of detail. Sequence diagrams can be drawn at different levels of details and also to meet different purposes at several stages in the development life-cycle. Analysis Sequence Diagrams normally do not include design objects Specify message in any detail Object Interaction -- 18 Page 9

Example: Add a new Campaign This SD is for the Use Case Add a new Campaign Add a new Campaign Staff Contact Add a new Campaign Description Find Client by Name Create New Campaign Find Creative Staff Member by Name Assign Campaign Manager Client New AssignManager Campaign CreativeStaff Object life line activation Object Interaction -- 19 Example: Add a new Campaign Title of Use Case Operations/Messages Add a new Campaign Description Find Client by Name Create New Campaign Find Creative Staff Member by Name Assign Campaign Manager Client New AssignManager Campaign CreativeStaff Statements System Boundary Objects Object Interaction -- 20 Page 10

Example: Printing :PrintDialogue :Spooler :Printer :Queue Print PrintFile(file) GetStatus Branching [Ready] Print [Offline] ErrorBox [Busy] PutInQueue (file) Ready GetNext Object Interaction -- 21 Notation The name of the class and the name of the instance of that class (object), if required, at the top of the column that represents it. Including the arrows marked makes it easier to follow the flow of control from object to object The vertical line for each object represents its lifeline The thick bar represents its activation i.e. when it is doing something Object Interaction -- 22 Page 11

Sequence Diagrams: UML This procedure call (operation) is creating an instance of class A createobj() obja:a objb:b doit() These return arrows are optional in a procedural flow of control Object Interaction -- 23 The box representing an object is drawn at the top if the object already exists, and at the point where the object is created if it is created within this use case, i.e. at the start of its lifeline Change Staff Member's Grade Sequence Diagrams: UML. Description :StaffMember :Grade OldGrade:StaffGrade Get StaffMember by Name - Change Grade (StaffName) ChangeGrade (ChangeDate, NewGrade) Get Existing Grade - Create New StaffGrade - New (StartDate) NewGrade:StaffGrade Set FinishDate of Old Grade - SetFinishDate (FinishDate) - Object Interaction -- 24 Page 12

Structures The statements in SDs can be structured using the three structures which are common to all computer programs: Sequence - one statement following another; ion - a choice between alternatives if statement if... else statement case statement Iteration - repeating statement(s) in a loop controlled by a condition for... next while... do... loop until... do... loop Object Interaction -- 25 Iteration Iteration (repetition of an operation) is shown with an asterisk Each StaffMember will be selected in turn Once selected, the CalculateBonus message will be sent to the one currently selected There is only one loop! Calculate Staff Bonuses Description Start For Each StaffMember next Staff Member Calculate Bonus for Staff Member Iteration * CalculateBonus StaffMember Object Interaction -- 26 Page 13

Drawing SDs For a particular use case, start by identifying which objects might be involved You may not get this right, but you can always change it Imagine that there is a use case required by Agate called Check Campaign Budget Each Campaign has an EstimatedCost attribute and each Advert has an EstimatedCost attribute The purpose of the use case is to check that the total estimated cost of all the adverts is less than that for the campaign as a whole. Which objects are involved? Object Interaction -- 27 Drawing SDs Campaign Class diagram showing aggregation Contains 1 * Advert Object Interaction -- 28 Page 14

Drawing SDs Class diagram for Campaign class Campaign +Title : String +CampaignStartDate : Date +CampaignFinishDate : Date +EstimatedCost : Money +ActualCost : Money +CompletionDate : Date +DatePaid : Date -StaffCount : Integer = 0 +Completed (CompletionDate : Date, ActualCost : Money) +SetFinishDate (FinishDate : Date) +RecordPayment (DatePaid : Date) +CostDifference ():Money +GetCampaignContribution ():Money +CheckBudget ():Money Object Interaction -- 29 Drawing SDs Class diagram for Advert class #Title : String #Type : String #TargetDate : Date #CompletedDate : Date #EstimatedCost : Money Advert +SetCompleted (CompletedDate : Date =Today's Date) +GetTitle () :String +GetType () :String +GetTargetDate () :Date +GetCompletedDate () :Date +GetCost () : Money Object Interaction -- 30 Page 15

Drawing SDs What is the first thing to do? the relevant Campaign, probably using its name How we select it may be something we leave until we get into design: it could be from a list box it could involve a separate window on the screen it could involve some kind of index These are design issues, which we shall leave for now, although we would document them if the customer expressed a preference at this stage Object Interaction -- 31 Drawing SDs Check Campaign Budget Description Campaign :Campaign :Advert We can add in a Check Campaign Budget Description :Campaign :Advert Campaign - Object Interaction -- 32 Page 16

Drawing SDs We then need to send a message to the Campaign to check its budget. Check Campaign Budget Description Campaign - Check Budget CheckBudget :Campaign :Advert Note there is no here. Where does control go? Object Interaction -- 33 Drawing SDs Check Campaign Budget Description :Campaign :Advert Campaign - Check Budget CheckBudget For each Advert Get Cost of Advert * GetCost Note the * for iteration. We are assuming here that the Campaign knows about all the Adverts that are contained in it by means of the Aggregation. Object Interaction -- 34 Page 17

Drawing SDs What happens next? Check Campaign Budget Description Campaign - Check Budget For each Advert Get Cost of Advert Cost of Advert CheckBudget :Campaign * GetCost :Advert Advert returns its cost, in this case the EstimatedCost of the Advert Object Interaction -- 35 Drawing SDs This has to happen for every Advert in the Campaign, so there s a loop Check Campaign Budget Description Campaign - Check Budget For each Advert Get Cost of Advert Cost of Advert Next Advert CheckBudget :Campaign * GetCost :Advert Once all the Adverts costs have been fetched and totalled up, the total can be taken away from the EstimatedCost of the Campaign. Object Interaction -- 36 Page 18

Drawing SDs Check Campaign Budget Description Campaign - Check Budget For each Advert Get Cost of Advert Cost of Advert Next Advert (Estimated Cost - Cost of Adverts) CheckBudget Campaign * GetCost Advert If it is negative, then the Campaign is likely to exceed its budget Object Interaction -- 37 Relationship to Class Diagram Advert #Title : String #Type : String #TargetDate : Date #CompletedDate : Date #EstimatedCost : Money #ActualCost : Money +SetCompleted (CompletedDate : Date =Today's Date) +GetTitle () :String +GetType () :String +GetTargetDate () :Date +GetCompletedDate () :Date +GetCost () : Money We could add a new attribute to Advert called ActualCost, which is set when the Advert is completed Now GetCost can return the ActualCost if it exists, otherwise the EstimatedCost Object Interaction -- 38 Page 19

Collaboration Diagram Emphasizes the organization of the objects that participate in an interaction. Shows interaction without the time dimension but do include object links. Collaboration diagrams are intended to model scenaria; each scenario describes a possible sequence of events and actions. For complex use cases use several collaboration diagrams; make sure each collaboration diagram is simple and easy to understand. Object Interaction -- 39 Collaboration Diagram The interaction starts from an actor. Links between objects are shown and may indicate the direction of navigability with arrowheads. Messages are shown beside the links with a directional arrow. Messages are numbered to show their sequence. Object Interaction -- 40 Page 20

Ex: Courses to Teach 1: Inform(courseList) : Professor 3:Propose(courseList ) 4:Agree(courseList ) :Administrator 2: *[for each professor] Inform(courseList) 5: Update(courseList ) AssociateChair :Professor <<entity>> : CourseInfo 6: *[For each course] Update() <<entity>> : CourseOffering 7: *[For each professor] Update() <<entity>> : ProfessorInfo Object Interaction -- 41 Ex: Add course offerring 1: add a course course options form 3: select course offering 2: display : Professor course form 5: get professor (professor id) 4: add professor (professor i d) course 6: add professor (professor) course offering Object Interaction -- 42 Page 21

Sequence Diagram X Collaboration Diagram Sequence diagrams and collaboration diagrams are semantically equivalent. You can take a diagram in one form and convert it to the other without loss of information. To model flows of control by time ordering (Sequence diagram). Emphasizes the passing of messages as they unfold over time -> visualization of Use Case scenario. To model flows of control by organization (Collaboration Diagram). Emphasizes the structural relationships among instances in the interaction -> visualization of multiple concurrent flows of control Object Interaction -- 43 Relationship to Class Diagram All operations shown on the collaboration and sequence diagrams must be present in the destination classes on the class diagram. Links shown on the collaboration diagram normally correspond to associations on the class diagram. Object Interaction -- 44 Page 22

Additional Readings [Booch99] Booch, G. et all. The Unified Modeling Language User Guide. Chapters 15, 18, 27. Addison-Wesley. [Jacobson92] Jacobson, I. et all. Object-Oriented Software Engineering: A Use-Case Driven Approach. Addison-Wesley. [Fowler00] Fowler, M. et all. UML Distilled: A Brief Guide to the Standard Object Modelling Language. Chapter 5. Addison-Wesley. Object Interaction -- 45 Page 23