Optional Case Study - Chapter 4

Slides:



Advertisements
Similar presentations
Interaction Diagram Notation From Chapter 15 of Craig Larman, Applying UML and Patterns John Dalesandro.
Advertisements

Ana M. Fernández  A UML diagram that depicts: ◦ interactions between objects. ◦ how the business currently works by showing how various.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
© 2005 Prentice Hall4-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Object Collaborations. Objectives: Object Interaction (cont.) You will be able to:  Use sequence diagrams to detail object interactions.
Sequence Diagram. What is Sequence Diagram?  Sequence Diagram is a dynamic model of a use case, showing the interaction among classes during a specified.
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
7M822 UML Interaction Diagrams 25 November 2010.
7M822 UML Sequence Diagrams 5 October 2009.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
1 Object Oriented Analysis and Design. 2 Object-Oriented Analysis  Statement of what our client wants Object-Oriented Design  How to provide it using.
CS3773 Software Engineering
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Introduction to Interaction Diagrams Used to illustrate the dynamic behaviour of a community of objects that collaborate by passing messages in order to.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 5 Outline 5.1 Introduction 5.2 Collaborations 5.3 Creating Collaborations.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 7 Outline 7.1 Introduction 7.2 Overview of Simulation Implementation.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 4 Outline 4.1 Introduction 4.2 Class Operations 4.3 Creating Class.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 3 Outline 3.1 Introduction 3.2 Class Attributes 3.3 Statechart Diagrams.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
1 State Modeling  Events  States  Transitions and Conditions  State Diagrams  State Diagram Behavior  Practical Tips.
 2002 Prentice Hall, Inc. All rights reserved. Appendix H – Elevator Model Outline H.1 Introduction H.2 Class ElevatorModel H.3Classes Location and Floor.
ANALYSIS - II REQUIREMENT ANALYSIS DESIGN IMPLEMENTATION TEST.
Collaboration Diagrams CSIS3600. What is a Collaboration Diagram Collaboration diagrams illustrate interactions between objects The collaboration diagram.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 2 Outline 2.1 Introduction 2.2 Thinking About Objects: Identifying.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
 C-style pointer-based arrays  Have great potential for errors and several shortcomings  C++ does not check whether subscripts fall outside the range.
Interaction Diagrams Interaction Diagrams allow the designer to show how groups of objects collaborate in some behavior. –Interaction Diagrams will show.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour UML Sequence Diagram.
COMP-350 Object-Oriented Analysis and Design Drawing System Sequence Diagrams Reference: Larman, Chapter 9.
Sequence Diagrams And Collaboration Diagrams HungNM.
Object Oriented Analysis and Design Sequence Diagrams.
1 Examining Execution Sequences Introducing Sequence Diagrams.
 2003 Prentice Hall, Inc. All rights reserved. Appendix E – Elevator Model Outline E.1 Introduction E.2 Class ElevatorSimulation E.3Classes Location and.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
 2006 Doan Van Ban, IOIT. All rights reserved. 1 Case Study: E levator System Simulation Program Goal –Software simulator application –N-floor elevator.
Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams.
Essentials of Counter-Controlled Repetition Counter-controlled repetition requires: Control variable (loop counter) Initial value of the control variable.
Sequence Diagram SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Sequence diagrams Practice 7. Task 1  The “Author” sends his paper to the “Editor” by the message “manuscript” and waits the confirmation.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 6: Restaurant.
 The Sequence Diagram models the collaboration of objects based on a time sequence.  It shows how the objects interact with others in a particular scenario.
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 6 Outline 6.1 Introduction 6.2 Implementation: Visibility 6.3 Implementation:
Project 2: Phase 1 Submission 7 Late submissions 10% 10 No submissions 14% Better than project 1 phase 3 submissions 10-point bonus: If you catch the deadline.
Sequence Diagram Lecture # 1. Sequence Diagram Definition A Sequence diagram is an interaction diagram that shows how the objects and classes involved.
GC211 Data structure Lecture 3 Sara Alhajjam.
Mile-long hurdle race Suppose that we want to program Karel to run a one-mile long hurdle race, where vertical wall sections represent hurdles. The hurdles.
Collaboration Diagrams
Chapter 4 The If…Then Statement
Unified Modeling Language (UML)
Standard UML: Communication and Dynamic Behavior
Interaction View.
Object-Oriented Systems Analysis and Design Using UML
Sequence Diagram.
Sequence Diagrams.
Interactions.
Object Oriented Analysis and Design
Princess Nourah bint Abdulrahman University
Internet Control Message Protocol Version 4 (ICMPv4)
Sequence Diagrams Lecture 6.
Classification of UML Diagrams
Chapter 11 Following the Trail; Examining Execution Sequences
IMAT5205 Systems Analysis and Design
Week 12: Activity & Sequence Diagrams
Java Programming Loops
Design and Implementation
Interaction diagrams Interaction diagrams are models that describe how groups of objects collaborate in some behavior. Typically, an interaction diagram.
Chapter 4 - Control Structures: Part 1
Chapter 4 Sequence Diagrams
Presentation transcript:

Optional Case Study - Chapter 4 Outline 4.1 Introduction 4.2 Class Operations 4.3 Creating Class Operations 4.4 Class Clock, Building 4.5 Class Scheduler 4.6 Class Person 4.7 Class Floor, FloorButton, ElevatorButton 4.8 Class Door 4.9 Sequence Diagrams 4.10 Conclusion

4.1 Introduction Previous chapters This chapter Chapter 5 Chapter 2 - identified classes Chapter 3 - determined many attributes of our classes This chapter Determine operations (behaviors) Chapter 5 Focus on interactions between classes

4.2 Class Operations Class operations Deriving operations Service class provides to clients Radio - setting station, volume Objects usually do not perform operations spontaneously Operations invoked by sending object (client object) Sends message to receiving object (server object) Requests object perform specific operation Deriving operations Examine problem statement for verbs and verb phrases Relate phrases to particular classes

4.2 Class Operations (II)

4.3 Creating Class Operations Creating operations Examine verb phrase "moves" verb is listed with Elevator Should "moves" be an operation? No message tells elevator to move Moves in response to a button, on condition that door is closed "Moves" should not be an operation "Arrives at floor" should not be an operation Elevator itself decides when to arrive, based on time "resets elevator button" - implies elevator sends message to elevator button, telling it to reset ElevatorButton needs an operation to provide this service to the elevator

4.3 Creating Class Operations (II) Format Write operation name in bottom compartment in class diagram Write operations as function names, include return type, parameters resetButton() : void Function takes no parameters, returns nothing Other verbs Bell - provides service of ringing Floor - signal arrival of elevator Door - open and close

4.3 Creating Class Operations (III) open : bool = false Door openDoor( ) : void closeDoor( ) : void <none yet> Bell ringBell( ) : void on : bool = false Light turnOff( ) : void turnOn( ) : void pressed : bool = false FloorButton pressButton( ) : void resetButton( ) : void time : int = 0 Clock getTime( ) : int tick( ) : void occupied : bool = false Floor elevatorArrived( ) : void isOccupied( ) : bool Person ID : int stepOntoFloor( ) : void exitElevator( ) : void enterElevator( ) : void ElevatorButton Elevator currentFloor : int = 1 direction : enum = up capacity : int = 1 arrivalTime : int moving : bool = false processTime( time : int ) : void personEnters( ) : void personExits( ) : void summonElevator( ) : void prepareToLeave( ) : void Scheduler floor1ArrivalTime : int floor2ArrivalTime : int Building runSimulation( ) : void

Building, once per second, will 4.4 Class Clock, Building Class Clock Has phrase "ticks every second" "Getting the time" is an operation clock provides Is the ticking also an operation? Look at how simulation works Building, once per second, will Get time from clock Give time to scheduler Give time to elevator Building has full responsibility for running simulation, therefore it must increment clock getTime and tick therefore operations of Clock processTime operation of Scheduler and Elevator

4.5 Class Scheduler Class Scheduler "randomly schedules times", "delays creating a person by one second" Scheduler performs these actions itself, does not provide service to clients "create person" - special case A Person object cannot respond to a create message because it does not yet exist Creation left to implementation details, not an operation of a class More Chapter 7 "tells a person to step onto a floor" - class Person should have a function that the scheduler can invoke stepOntoFloor - operation of class Person

4.6 Class Person More verb phrases Class Person "verifies a floor is unoccupied" - class Floor needs a service to let other objects know if a floor is occupied or not isOccupied returns true or false Class Person "presses floor button", "presses elevator button" Place operation pressButton under classes FloorButton and ElevatorButton "enter elevator", "exit elevator" - suggests class Elevator needs operations to correspond to these actions Discover what, if any, actions operations perform when concentrate on implementation

4.7 Class Floor, FloorButton, ElevatorButton "resets floor button" - resetButton operation "turns off light", "turns on light" - turnOff and turnOn in class Light Class FloorButton and ElevatorButton "summons elevator" - summonElevator operation in class Elevator "signals elevator to move" - elevator needs to provide a "move" service Before it can move, must close door prepareToLeave operation (performs necessary actions before moving) in class Elevator

4.8 Class Door Class Door Notes Phrases imply door sends message to person to tell it to exit or enter elevator exitElevator and enterElevator in class Person Notes We do not overly concern ourselves with parameters or return types Only want a basic understanding of each class As we continue design, number of operations may vary New operations needed Some current operations unnecessary

4.9 Sequence Diagrams Sequence Diagram Format Model our "Simulation loop" Focuses on how messages are sent between objects over time Format Each object represented by a rectangle at top of diagram Name inside rectangle (objectName) Lifeline - dashed vertical line, represents progression of time Actions occur along lifeline in chronological order, top to bottom Line with arrowhead - message between objects Invokes corresponding operation in receiving object Arrowhead points to lifeline of receiving object Name of message above message line, includes parameters Parameter name followed by colon and parameter type

4.9 Sequence Diagrams (II) : Building {currentTime < totalTime} tick( ) getTime( ) processTime( currentTime : int ) processTime( currentTime : int ) time : Scheduler : Clock : Elevator

4.9 Sequence Diagrams (III) Flow of control If object returns flow of control or returns a value, return message (dashed line with arrowhead) goes back to original object Clock object returns time in response to getTime message received from Building object Activations Rectangles along lifelines - represent duration of an activity Height corresponds to duration Timing constraint In our diagram, text to far left While currentTime < totalTime objects keep sending messages as in the diagram

building sends processTime message to scheduler processTime( time ) bool isOccupied( ) : bool : Person scheduleArrival( floor1 ) personArrives( ) [occupied = false] create [occupied = true] scheduleArrival( floor2 ) building : Building scheduler : Scheduler floor1 : Floor floor2 : Floor delayArrival( floor1 ) delayArrival( floor2 ) building sends processTime message to scheduler scheduler decides whether to create a new person Can only create a new person if floor unoccupied Checks by sending isOccupied message to floor object The two lifelines converge scheduler handles second floor same way as the first When finished, returns control to building floor1 returns true or false scheduler's lifeline splits - conditional execution of activities. Condition supplied for each lifeline. If true - scheduler calls delayArrival Not an operation - not invoked by another object If false - scheduler creates new Person object When new objects created, rectangle corresponds to time. Message "create" sent from one object to another (arrowhead points to new object). After new Person object created, it steps on first floor Person object sends personArrives message to floor1 object scheduler schedules new arrival for floor1 calls its own scheduleArrival function (not an operation)

Discussed operations of classes Chapter 5 4.10 Conclusion Discussed operations of classes Introduced sequence diagrams to illustrate operations Chapter 5 Examine how objects interact with each other