Chapter 2, Modeling with UML, Part 2

Similar documents
Chapter 2, Modeling with UML, Part 2

Chapter 2, Modeling with UML, Part 2

Chapter 2, lecture 2 Modeling with UML

Chapter 2, Modeling with UML, Part 2

MSc programme (induction week) Department of Informatics INTRODUCTION TO UML

Chapter 2, Modeling with UML

Chapter 2, Modeling with UML

Chapter 2, Modeling with UML

Design Patterns. Design Patterns

Course "Softwaretechnik Modeling with UML Stephan Salinger

Software Engineering

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

Object Relationships UML Class diagrams. Software Requirements and Design CITS 4401 Lecture 4

2. Modeling with UML

Recap : UML artefacts. Black Box Requirements. Functional Specification. System. System. Test. Design. System. System. Development.

Modern methods in Software Engineering UML.

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

Chapter 2, lecture 1, Modeling with UML

Unified Modeling Language (UML)

Unified Modeling Language (UML)

Overview of the OOA Process...

Chapter 5, Analysis: Dynamic Modeling

Chapter 5, Analysis: Object Modeling

Lecture 16+17: Modeling with UML

A Rapid Overview of UML

Lecture 15: Modeling with UML

Chapter 5, Object Modeling

Chapter 5, Analysis: Dynamic Modeling

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 09/29/2015

Chapter 5, Analysis: Dynamic Modeling

Engineering Design w/embedded Systems

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Chapter 4 Requirements Elicitation

Use Case Modeling. Bernd Bruegge Carnegie Mellon University School of Computer Science. 8 September Bernd Brügge Software Engineering 1

Object Design II: Design Patterns

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

CMSC 132: Object-Oriented Programming II

CSE 308. UML Overview Use Case Diagrams. Reference. en.wikipedia.org/wiki/class_diagram. Robert Kelly, B. Bruegge,

Object-Oriented and Classical Software Engineering

Software Service Engineering

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Modeling with UML. (1) Use Case Diagram. (2) Class Diagram. (3) Interaction Diagram. (4) State Diagram

Modeling with UML eerin gin n are E oftw S ted rien ject-o b O

Lecture 33 April 4, Unied Modelling Language. ECE155: Engineering Design with Embedded Systems Winter Patrick Lam version 1

Progress Report. Object-Oriented Software Development: Requirements elicitation (ch. 4) and analysis (ch. 5) Object-oriented software development

Object-Oriented Design

Page 1. Dynamic Modeling. How do you find classes? Dynamic Modeling with UML. UML Interaction Diagrams. UML State Chart Diagram.

Progress Report. Object-Oriented Software Development: Requirements elicitation and analysis. Object-oriented analysis, design, implementation

Software Engineering Fall 2014

Question Sheet There are a number of criticisms to UML. List a number of these criticisms.

UML Primer. -Elango Sundaram

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Interaction Modelling: Sequence Diagrams

Object Oriented Modeling

Meltem Özturan

Introduction to Software Engineering: Analysis

UML Tutorial. Unified Modeling Language UML Tutorial

Class modelling (part 2)

CSE 308. UML Overview Use Case Diagrams. Reference. Class diagrams. Session 6 UML Intro/Use cases. Robert Kelly, B. Bruegge,

Objectives. Explain the purpose and objectives of objectoriented. Develop design class diagrams

Class modelling (part 2)

Today s Topic. Lecture 5. What is UML? Why Use UML. UML Diagrams. Introduction to UML. What is UML Why use UML? UML Diagrams

Chapter 7, System Design: Addressing Design Goals

Outline of UML and Unified Process. Object Oriented Analysis/Design/Programming UML1.5. Koichiro Ochimizu, JAIST. UML&UP outline 1.

Interactions A link message

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

SOFTWARE ENGINEERING UML FUNDAMENTALS. Saulius Ragaišis.

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD TM : ,

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

UML Modeling I. Instructor: Yongjie Zheng September 3, CS 490MT/5555 Software Methods and Tools

From Analysis to Design. LTOOD/OOAD Verified Software Systems

Object-oriented development. Object-oriented Design. Objectives. Characteristics of OOD. Interacting objects. Topics covered

Introduction to Software Engineering. 5. Modeling Objects and Classes

Object-Oriented Systems Analysis and Design Using UML

CS 370 REVIEW: UML Diagrams D R. M I C H A E L J. R E A L E F A L L

Overview of the OOA Process...

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

CS 451 Software Engineering

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

Week 9 Implementation

UML Views of a System

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

OBJECT ORIENTED DESIGN with the Unified Process. Use Case Realization

UNIT-4 Behavioral Diagrams

Introduction to Software Engineering. 6. Modeling Behaviour

Computer Science for Engineers

Software Engineering Fall 2015 (CSC 4350/6350) TR. 5:30 pm 7:15 pm. Rao Casturi 09/17/2015

Advanced Interaction

Requirements Elicitation

Interaction Modelling: Use Cases

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

Lab Manual. Object Oriented Analysis And Design. TE(Computer) VI semester

CSCU9T4: Managing Information

MechEng SE3 Lecture 7 Domain Modelling

Unit Wise Questions. Unit-1 Concepts

Unit-4 OBJECT ORIENTED DESIGN WORKFLOW

LABORATORY 1 REVISION

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

Chapter 10 Object-Oriented Design Principles

Transcription:

Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 2, Modeling with UML, Part 2 Outline of this Class What is UML? A more detailed view on ü Use case diagrams ü Class diagrams ü Sequence diagrams ü Activity/Statecharts diagrams Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 2! 1!

UML Basic Notation: First Summary UML provides a wide variety of notations for modeling many aspects of software systems UML diagrams cover the three fundamental models for software design: Functional model: Use case diagrams Object model: Class diagrams Dynamic model: Sequence diagrams, statechart diagram Now we go into a little bit more detail Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 3! UML First Pass (covered in Last Lecture) Use case diagrams Describe the functional behavior of the system as seen by the user Class diagrams Describe the static structure of the system: Objects, attributes, associations Sequence diagrams Describe the dynamic behavior between objects of the system Statechart diagrams Describe the dynamic behavior of an individual object Activity diagrams Describe the dynamic behavior of a system, in particular the workflow. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 4! 2!

UML Use Case Diagram Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 5! UML first pass: Use case diagrams Classifier" Use Case" Actor." System boundary" Use case diagrams represent the functionality of the system" from user s point of view" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 6! 3!

UML Use Case Diagrams Passenger" Used during requirements elicitation and analysis to represent external behavior ( visible from the outside of the system ) An Actor represents a role, that is, a type of user of the system A use case represents a class of functionality provided by the system PurchaseTicket" Use case model: The set of all use cases that completely describe the functionality of the system. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 7! Actors Passenger" Name! An actor is a model for an external entity which interacts (communicates) with the system: User External system (Another system) Physical environment (e.g. Weather) An actor has a unique name and an optional description Optional! Examples: Description! Passenger: A person in the train GPS satellite: An external system that provides the system with GPS coordinates. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 8! 4!

Use Case PurchaseTicket" A use case represents a class of functionality provided by the system Use cases can be described textually, with a focus on the event flow between actor and system The textual use case description consists of 6 parts: 1. Unique name 2. Participating actors 3. Entry conditions 4. Exit conditions 5. Flow of events 6. Special requirements. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 9! Textual Use Case Description Example 1. Name: Purchase ticket 2. Participating actor: Passenger 3. Entry condition: (GOOD) Passenger selects an option from the display! (WRONG) Passenger stands in front of ticket distributor (Very WRONG) Passenger has sufficient money to purchase ticket 4. Exit condition: Passenger has ticket (Better): System delivered ticket Passenger" PurchaseTicket" 5. Flow of events: 1. Passenger selects the number of zones to be traveled 2. Distributor displays the amount due 3. Passenger inserts money, at least the amount due 4. Ticket Distributor returns change 5. Ticket Distributor issues ticket 6. Special requirements: None. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 10! 5!

Uses Cases can be related Extends Relationship To represent seldom invoked use cases or exceptional functionality Includes Relationship To represent functional behavior common to more than one use case. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 11! The <<extends>> Relationship <<extends>> relationships model exceptional or seldom invoked cases <<extends>>! Passenger" PurchaseTicket" The exceptional event flows are factored out of the main event flow for clarity The direction of an <<extends>> relationship is to the extended use case Use cases representing exceptional flows can extend more than one use case. <<extends>>! <<extends>>! OutOfOrder" <<extends>>! TimeOut" Cancel" NoChange" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 12! 6!

The <<includes>> Relationship <<includes>> relationship represents common functionality needed in more than one use case Passenger" <<includes>> behavior is factored out for reuse, not PurchaseMultiCard" because it is an exception The direction of a PurchaseSingleTicket" <<includes>> relationship is <<includes>>! to the using use case (unlike <<includes>>! the direction of the <<extends>> relationship). <<extends>>! CollectMoney" <<extends>>! <<extends>>! NoChange" Cancel" Cancel" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 13! Use Case Models can be packaged Classifier" Use Case" Actor." System boundary" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 14! 7!

Historical Remark: UML 1 used packages Package" Course" Instructor" GiveLecture" HoldExercise" Student" Teaching! Assistent! DoHomework" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 15! UML Class Diagram Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 16! 8!

UML first pass: Class diagrams Association" Multiplicity" 2 PushButton Class" SimpleWatch 1 1 1 1 1 2 1 Display Battery Time Class diagrams represent the structure of the system" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 17! UML first pass: Class diagrams Class diagrams represent the structure of the system" Association" Class" Multiplicity" 2" PushButton!! state! push() release()" Attribute" 1" 1" LCDDisplay! blinkidx! blinkseconds()! blinkminutes()! blinkhours()! stopblinking()! referesh()" Watch" 1" 1" 1" 2" Battery! Load" 1" Time! Now" Operations" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 18! 9!

Class Diagrams Class diagrams represent the structure of the system Used during requirements analysis to model application domain concepts during system design to model subsystems during object design to specify the detailed behavior and attributes of classes. TarifSchedule! Table zone2price! Enumeration getzones()! Price getprice(zone)! *" *" Trip! zone:zone! Price: Price! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 19! Classes Type" TarifSchedule! zone2price! getzones()! getprice()! Name" Attributes" Operations" TarifSchedule! Table zone2price! Enumeration getzones()! Price getprice(zone)! Signature" TarifSchedule! A class represents a concept A class encapsulates state (attributes) and behavior (operations) Each attribute has a type Each operation has a signature The class name is the only mandatory information Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 20! 10!

Actor vs Class vs Object Actor An entity outside the system to be modeled, interacting with the system ( Passenger ) Class An abstraction modeling an entity in the application or solution domain The class is part of the system model ( User, Ticket distributor, Server ) Object A specific instance of a class ( Joe, the passenger who is purchasing a ticket from the ticket distributor ). Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 21! Instances tarif2006:tarifschedule! zone2price = {! { 1, 0.20}, { 2, 0.40},! { 3, 0.60}}! :TarifSchedule! zone2price = {! { 1, 0.20}, { 2, 0.40},! { 3, 0.60}}! An instance represents a phenomenon The attributes are represented with their values The name of an instance is underlined The name can contain only the class name of the instance (anonymous instance) Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 22! 11!

Associations TarifSchedule!! Enumeration getzones()! Price getprice(zone)! *" *" TripLeg! Price Zone!! Associations denote relationships between classes The multiplicity of an association end denotes how many objects the instance of a class can legitimately reference. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 23! 1-to-1 and 1-to-many Associations Country! name:string" 1! 1! City! name:string" 1-to-1 association Polygon! draw()" Point! x: Integer" y: Integer" 1-to-many association Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 24! 12!

Many-to-many Associations StockExchange Lists Company tickersymbol A stock exchange lists many companies. Each company is identified by a ticker symbol Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 25! From Problem Statement To Object Model Problem Statement: A stock exchange lists many companies. Each company is uniquely identified by a ticker symbol Class Diagram:! StockExchange Lists Company tickersymbol Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 26! 13!

From Problem Statement to Code Pr oblem Statement : A stock exchange lists many companies. Each company is identified by a ticker symbol Class Diagram:! StockExchange Lists Company tickersymbol Java Code! public class StockExchange { private Vector m_company = new Vector(); }; public class Company { public int m_tickersymbol; private Vector m_stockexchange = new Vector(); }; Associations! are mapped to! Attributes!! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 27! Qualifiers Without qualification" 1" *" Directory" File" filename" With qualification" Directory" filename" 1" 0..1" File" Qualifiers can be used to reduce the multiplicity of an association Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 28! 14!

Qualification: Another Example StockExchange Lists Company tickersymbol StockExchange tickersymbol Lists 1! Company Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 29! Aggregation An aggregation is a special case of association denoting a consists-of hierarchy Exhaust system! The aggregate is the parent class, the components are the children classes 1" 0..2" Muffler! diameter" Tailpipe! diameter" A solid diamond denotes composition: A strong form of aggregation where the life time of the component instances is controlled by the aggregate. That is, the parts don t exist on their won ( the whole controls/destroys the parts ) TicketMachine! 3" ZoneButton! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 30! 15!

Inheritance Button! CancelButton! ZoneButton! Inheritance is another special case of an association denoting a kind-of hierarchy Inheritance simplifies the analysis model by introducing a taxonomy The children classes inherit the attributes and operations of the parent class. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 31! Packages Packages help you to organize UML models to increase their readability We can use the UML package mechanism to organize classes into subsystems Account" Bank" Customer" Any complex system can be decomposed into subsystems, where each subsystem is modeled as a package. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 32! 16!

Object Modeling in Practice Foo! Amount! CustomerId! Deposit()! Withdraw()! GetBalance()! Class Identification: Name of Class, Attributes and Methods Is Foo the right name?! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 33! Object Modeling in Practice: Brainstorming Dada! Amount! CustomerId! Deposit()! Withdraw()! GetBalance()! Foo! Amount! CustomerId! Deposit()! Withdraw()! GetBalance()! Account! Amount! CustomerId!! Is Foo the right name? Deposit()! Withdraw()! GetBalance()! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 34! 17!

Object Modeling in Practice: More classes Account! Bank! Name! Amount! CustomerId! AccountId! Deposit()! Withdraw()! GetBalance()! Customer! Name! CustomerId! 1) Find New Classes! 2) Review Names, Attributes and Methods! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 35! Object Modeling in Practice: Associations Account! Bank! Name!?! has! Amount! CustomerId! AccountId! AccountId! Deposit()! Withdraw()! GetBalance()! owns! 2! Customer! Name! CustomerId! 1) Find New Classes! 2) Review Names, Attributes and Methods! 3) Find Associations between Classes! 4) Label the generic assocations! 5) Determine the multiplicity of the assocations! 6) Review associations! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 36! 18!

Practice Object Modeling: Find Taxonomies Bank! Name! Account! Amount! CustomerId! AccountId! AccountId! Has! Customer! Name! Deposit()! Withdraw()! GetBalance()! CustomerId()! Savings! Account! Checking! Account! Mortgage! Account! Withdraw()! Withdraw()! Withdraw()! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 37! Practice Object Modeling: Simplify, Organize Account! Amount! CustomerId! AccountId! AccountId! Deposit()! Withdraw()! GetBalance()! Show Taxonomies! separately! Savings! Account! Checking! Account! Mortgage! Account! Withdraw()! Withdraw()! Withdraw()! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 38! 19!

Practice Object Modeling: Simplify, Organize Bank! Name! Account! Amount! CustomerId! AccountId! AccountId! Has! Customer! Name! Deposit()! Withdraw()! GetBalance()! CustomerId()! Use the 7+-2 heuristics! or better 5+-2!! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 39! UML Sequence Diagram Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 40! 20!

UML first pass: Sequence diagram Actor" Message" Object" Lifeline" :WatchUser" pressbutton1()" pressbutton1()" pressbutton2()" :Watch" blinkhours()" blinkminutes()" :LCDDisplay" incrementminutes()" pressbutton1and2()" commitnewtime()" refresh()" :Time" Activation" stopblinking()" Sequence diagrams represent the behavior of a system " as messages ( interactions ) between different objects" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 41! Sequence Diagrams Focus on! Controlflow! Passenger" TicketMachine" selectzone()" insertcoins()" pickupchange()" pickupticket()" Used during analysis To refine use case descriptions to find additional objects ( participating objects ) Used during system design TicketMachine! to refine subsystem interfaces zone2price! Instances are represented Messages ->" by selectzone()! rectangles. Actors Operations by sticky on" insertcoins()! figures participating Object" pickupchange()! Lifelines are represented by pickupticket()! dashed lines Messages are represented by arrows Activations are represented by narrow rectangles. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 42! 21!

Scenarios, use case and sequence diagrams A scenario is an instance of a use case describing a concrete set of actions (no alternative paths are in it) A use case is an abstraction that describes all possible scenarios involving the described functionality. Scenarios are used as examples for illustrating common cases; their focus is on understandability. Use cases are used to describe all possible cases; their focus is on completeness. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 43! How to describe scenarios We describe a scenario using a template with three fields: The name of the scenario enables us to refer to it unambiguously. The name of a scenario is underlined to indicate that it is an instance. The participating actor instances field indicates which actor instances are involved in this scenario. Actor instances also have underlined names. The flow of events of a scenario describes the sequence of events step by step. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 44! 22!

Scenario: an example Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 45! Sequence Diagrams can also model the Flow of Data Passenger" ZoneButton" TarifSchedule" Display" selectzone()" lookupprice(selection)" Dataflow" price" displayprice(price)" continued on next slide..." The source of an arrow indicates the activation which sent the message Horizontal dashed arrows indicate data flow, for example return results from a message Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 46! 23!

Sequence Diagrams: Iteration & Condition continued from previous slide..." Passenger" ChangeProcessor" CoinIdentifier" Display" CoinDrop" insertchange(coin)" lookupcoin(coin)" price" Iteration" displayprice(owedamount)" Condition" [owedamount<0] returnchange(-owedamount)" continued on next slide... Iteration is denoted by a * preceding the message name Condition is denoted by boolean expression in [ ] before the message name Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 47! Creation and destruction continued from previous slide..." Passenger" ChangeProcessor" createticket(selection)" Ticket" print()" Creation of Ticket" free()" Destruction of Ticket" Creation is denoted by a message arrow pointing to the object Destruction is denoted by an X mark at the end of the destruction activation In garbage collection environments, destruction can be used to denote the end of the useful life of an object. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 48! 24!

Message Types Asynchronous Synchronous Call and Object creation Reply Lost Found Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 49! Sequence Diagram Properties UML sequence diagram represent behavior in terms of interactions Useful to identify or find missing objects Time consuming to build, but worth the investment Complement the class diagrams (which represent structure). Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 50! 25!

UML Statechart Diagram Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 51! UML first pass: Statechart diagrams Event" button1&2pressed Blink Hours Initial state" button2pressed Increment Hours Transition" button1pressed State" button1&2pressed Blink Minutes button2pressed Increment Minutes button1pressed Stop Blinking Blink Seconds button2pressed Increment Seconds Final state" Represent behavior of a single object with interesting dynamic behavior." Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 52! 26!

State machine diagram for 2Bwatch Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 53! Internal transitions in 2BWatch statechart Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 54! 27!

UML Activity Diagram Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 55! UML Activity Diagrams An activity diagram consists of nodes and edges Nodes describe activities and objects Control nodes Executable nodes Most prominent: Action Object nodes E.g. a document Edge is a directed connection between nodes There are two types of edges Control flow edges Object flow edges Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 56! 28!

Example: Structure of the Text Book Problem Statement" Object Node! Requirements" elicitation ("Ch.4)" An object node is an activity node that indicates an instance of a particular classifier, possibly in a particular state" nonfunctional requirements" functional model" use case diagram" " Analysis (Ch.5)" class diagram" " System design" ("Ch.6" & 7" )" analysis object model" dynamic model" " statechart diagram" " sequence diagram" " Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 57! Example: Structure of the Text Book (2) System design! (Ch. 6 & 7)!! subsystem decomposition! design goals! Object design! (Ch. 8 & 9)!! class diagram! object design model! Test (Ch. 11)!! source code! deliverable system! Implementation! (Ch. 10)!! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 58! 29!

Activity Diagrams: Grouping of Activities Activities may be grouped into swimlanes to denote the object or subsystem that implements the activities. Allocate! Resources! Dispatcher! Open! Incident! Coordinate! Resources! Archive! Incident! Document! Incident! FieldOfficer! Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 59! State Chart Diagrams vs Activity Diagrams An activity diagram that contains only activities can be seen as a special case of a state chart diagram Such an activity diagram is useful to describe the overall workflow of a system Handle Incident Document Incident Archive Incident Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 60! 30!

Statechart Diagram vs Activity Diagram Statechart Diagram for Incident! Focus on the set of attributes of a single abstraction (object, system)! Event causes" state transition" Active! Inactive! Closed! Archived! Incident-! Incident-! Incident-! Handled! Documented! Archived! Activity Diagram for Incident! (Focus on dataflow in a system)! Handle Incident Document Incident Archive Incident Completion of activity " causes state transition" Triggerless" transition" Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 61! What should be done first? Coding or Modeling? It depends. Forward Engineering Creation of code from a model Start with modeling Greenfield projects Reverse Engineering Creation of a model from existing code Interface or reengineering projects Roundtrip Engineering Move constantly between forward and reverse engineering Reengineering projects Useful when requirements, technology and schedule are changing frequently. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 62! 31!

Additional References Martin Fowler UML Distilled: A Brief Guide to the Standard Object Modeling Language, 3rd ed., Addison-Wesley, 2003 Grady Booch,James Rumbaugh,Ivar Jacobson The Unified Modeling Language User Guide, Addison Wesley, 2 nd edition, 2005 Open Source UML tools Astah Community: http://astah.net/editions/community http://java-source.net/open-source/uml-modeling Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 63! UML Summary UML provides a wide variety of notations for representing many aspects of software development Powerful, but complex UML is a programming language Can be misused to generate unreadable models Can be misunderstood when using too many exotic features We concentrated on a few notations: Functional model: Use case diagram Object model: class diagram Dynamic model: sequence diagrams, statechart and activity diagrams. Bernd Bruegge & Allen H. Dutoit!! Object-Oriented Software Engineering: Using UML, Patterns, and Java 64! 32!