 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 4 Outline 4.1 Introduction 4.2 Class Operations 4.3 Creating Class.

Slides:



Advertisements
Similar presentations
Object-Oriented Analysis and Design CHAPTERS 15: UML INTERACTION DIAGRAMS 1.
Advertisements

Interaction Diagram Notation From Chapter 15 of Craig Larman, Applying UML and Patterns John Dalesandro.
Chapter 6: Behavioral Modeling
Ana M. Fernández  A UML diagram that depicts: ◦ interactions between objects. ◦ how the business currently works by showing how various.
 2001 Prentice Hall, Inc. All rights reserved. 1 Appendix D – Elevator Events and Listener Interfaces Outline D.1 Introduction D.2 Events D.3Listeners.
Fundamentals of Computer Science Lecture 14: Recursion Instructor: Evan Korth New York University.
Chapter 12 ATM Case Study, Part 1: Object-Oriented Design with the UML
Computer Science II Recursion Professor: Evan Korth New York University.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 4 – C Program Control Outline 4.1Introduction.
Slide 6B.1 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. An Introduction to Object-Oriented Systems Analysis and Design with.
© 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.
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.
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
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
© 2008, Renesas Technology America, Inc. All Rights Reserved The RCAN-ET peripheral and the CAN API SH2 & SH2A MCUs V 1.2 Mar 2010.
Interaction diagrams Sequence and collaboration diagrams.
© 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.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Chapter 1 - Getting to know Greenfoot
 2000 Deitel & Associates, Inc. All rights reserved. Optional Case Study - Chapter 3 Outline 3.1 Introduction 3.2 Class Attributes 3.3 Statechart Diagrams.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML Sequence Diagrams.
Session 22 Modeling the Extended Features of the Statechart Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 27, 2011 Presented.
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.
2Object-Oriented Program Development Using C++ 3 Basic Loop Structures Loops repeat execution of an instruction set Three repetition structures: while,
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour UML Sequence Diagram.
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.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
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.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
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.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
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:
GC211 Data structure Lecture 3 Sara Alhajjam.
Collaboration Diagrams
Object-Oriented Systems Analysis and Design Using UML
Optional Case Study - Chapter 4
Sequence Diagram.
Object Oriented System Design COS 50-3
Sequence Diagrams.
תכן UML in Design מקורות: S. R. Schach: Chapter 12
IMAT5205 Systems Analysis and Design
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
Presentation transcript:

 2000 Deitel & Associates, Inc. All rights reserved. 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

 2000 Deitel & Associates, Inc. All rights reserved. 4.1 Introduction Previous chapters –Chapter 2 - identified classes –Chapter 3 - determined many attributes of our classes This chapter –Determine operations (behaviors) Chapter 5 –Focus on interactions between classes

 2000 Deitel & Associates, Inc. All rights reserved. 4.2 Class Operations Class 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

 2000 Deitel & Associates, Inc. All rights reserved. 4.2 Class Operations (II)

 2000 Deitel & Associates, Inc. All rights reserved. 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

 2000 Deitel & Associates, Inc. All rights reserved. 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

 2000 Deitel & Associates, Inc. All rights reserved. 4.3 Creating Class Operations (III) open : bool = false Door openDoor( ) : void closeDoor( ) : void 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 pressed : bool = false ElevatorButton resetButton( ) : void pressButton( ) : void 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 processTime( time : int ) : void Building runSimulation( ) : void

 2000 Deitel & Associates, Inc. All rights reserved. 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

 2000 Deitel & Associates, Inc. All rights reserved. 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

 2000 Deitel & Associates, Inc. All rights reserved. 4.6 Class Person More verb phrases –"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

 2000 Deitel & Associates, Inc. All rights reserved. 4.7 Class Floor, FloorButton, ElevatorButton Class Floor –"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

 2000 Deitel & Associates, Inc. All rights reserved. 4.8 Class Door Class Door –Phrases imply door sends message to person to tell it to exit or enter elevator –exitElevator and enterElevator in class Person Notes –Do not overly worry about 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

 2000 Deitel & Associates, Inc. All rights reserved. 4.9 Sequence Diagrams Sequence Diagram –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 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

 2000 Deitel & Associates, Inc. All rights reserved. 4.9 Sequence Diagrams (II) : Building { currentTime < totalTime } tick( ) getTime( ) processTime( currentTime : int ) time : Scheduler: Clock: Elevator

 2000 Deitel & Associates, Inc. All rights reserved. 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

 2000 Deitel & Associates, Inc. All rights reserved. processTime( time ) bool isOccupied( ) : bool : Person scheduleArrival( floor1 ) personArrives( ) [ occupied = false ] create [ occupied = false ] create [ occupied = true ] bool isOccupied( ) : bool personArrives( ) scheduleArrival( floor2 ) building : Building scheduler : Scheduler floor1 : Floor floor2 : Floor : Person 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 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) The two lifelines converge scheduler handles second floor same way as the first When finished, returns control to building

 2000 Deitel & Associates, Inc. All rights reserved Conclusion Discussed operations of classes –Introduced sequence diagrams to illustrate operations Chapter 5 –Examine how objects interact with each other