1 modeling with uml cmpe 131 fall 2003. 2 overview what is modeling? what is uml? use case diagrams...
Post on 15-Jan-2016
217 views
TRANSCRIPT
![Page 1: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/1.jpg)
1
Modeling with UML
CMPE 131
Fall 2003
![Page 2: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/2.jpg)
2
Overview
• What is modeling?
• What is UML?
• Use case diagrams
• Class diagrams
• Sequence diagrams
• Activity diagrams
• Summary
![Page 3: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/3.jpg)
3
Systems, Models, and Views
• A model is an abstraction describing system or a subset of a system
• A view depicts selected aspects of a model• A notation is a set of graphical or textual
rules for representing views• Views and models of a single system may
overlap each other
![Page 4: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/4.jpg)
4
Systems, Models, and Views
SystemView 1
Model 2View 2
View 3
Model 1
Airplane
Flightsimulator
Scale Model
Blueprints
Electrical Wiring
![Page 5: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/5.jpg)
5
Why Model Software?Software is already an abstraction: why model
software?
Software is getting larger, not smaller– NT 5.0 ~ 40 million lines of code– A single programmer cannot manage this amount of code in
its entirety.
• Code is often not directly understandable by developers who did not participate in the development
• We need simpler representations for complex systems– Modeling is a mean for dealing with complexity
![Page 6: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/6.jpg)
6
Concepts & Phenomena• Phenomenon: An object in the world of a domain as you perceive it,
for example:– The lecture you are attending
– My black watch
• Concept: Describes the properties of phenomena that are common, for example:– Lectures on software engineering
– Black watches
• A concept is a 3-tuple: – Its Name distinguishes it from other concepts.
– Its Purpose are the properties that determine if a phenomenon is a member of a concept.
– Its Members are the phenomena which are part of the concept.
![Page 7: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/7.jpg)
7
ClockA device thatmeasures time.
A Concept Is a 3-tuple
Name Purpose Members
![Page 8: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/8.jpg)
8
Concepts In Software
• The type of a variable represents all possible instances the variable can take.
• The relationship between type & instance is similar to that of concept & phenomenon.
• Abstract data type (ADT)– Special type whose implementation is hidden from
the rest of the system.
![Page 9: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/9.jpg)
9
Class
• A class is an abstraction in the context of object-oriented languages
• Like an abstract data type, a class encapsulates both state (variables) and behavior (methods)
• Unlike abstract data types, classes can be defined in terms of other classes using inheritance
![Page 10: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/10.jpg)
10
Two Classes
Watch
timedate
CalculatorWatchSetDate(d)
EnterCalcMode()InputNumber(n)
calculatorState
![Page 11: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/11.jpg)
11
Object-Oriented Modeling
UML Package
Application Domain Solution DomainApplication Domain Model System Model
AircraftTrafficController
FlightPlan Airport
MapDisplay
FlightPlanDatabase
SummaryDisplay
TrafficControl
TrafficControl
![Page 12: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/12.jpg)
12
Application & Solution Domain
• Application Domain – Requirements & analysis– The environment in which the system is
operating
• Solution Domain– System design & object Design– The available technologies to build the
system
![Page 13: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/13.jpg)
13
Unified Modeling Language
• An emerging standard for modeling object-oriented software.
• Resulted from the convergence of notations from three leading object-oriented methods:– OMT (James Rumbaugh)– OOSE (Ivar Jacobson)– Booch (Grady Booch)
![Page 14: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/14.jpg)
14
UML Diagrams
• 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, and
Associations.
• Sequence diagrams– Describe the dynamic behavior between actors and the system and
between objects of the system.
• Statechart diagrams– Describe the dynamic behavior of an individual object as a finite state
machine.
• Activity diagrams– Model the dynamic behavior of a system, in particular the workflow,
i.e. a flowchart.
![Page 15: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/15.jpg)
15
Use Case Diagram
WatchUser WatchRepairPerson
ReadTime
SetTime
ChangeBattery
Actor
Use case
PackageSimpleWatch
Use case diagrams represent the functionality of the systemfrom user’s point of view
![Page 16: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/16.jpg)
16
Class Diagram
Batteryload()
1
2
Timenow()
PushButtonstatepush()release()
1
1
1
1
1
2
blinkIdxblinkSeconds()blinkMinutes()blinkHours()stopBlinking()referesh()
LCDDisplay
SimpleWatch
Class
AssociationMultiplicity
Attributes
Operations
Class diagrams represent the structure of the system
![Page 17: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/17.jpg)
17
Sequence DiagramObject
MessageActivation
Sequence diagrams represent the behavior as interactions
blinkHours()
blinkMinutes()
incrementMinutes()
refresh()
commitNewTime()
stopBlinking()
pressButton1()
pressButton2()
pressButtons1And2()
pressButton1()
:WatchUser:Time:LCDDisplay:SimpleWatch
![Page 18: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/18.jpg)
18
button1&2Pressed
button1&2Pressed
button1Pressed
button2Pressed
button2Pressed
button2Pressed
button1Pressed
button1&2Pressed IncrementMinutes
IncrementHours
BlinkHours
BlinkSeconds
BlinkMinutes
IncrementSeconds
StopBlinking
Statechart DiagramStateInitial state
Final state
Transition
Event
![Page 19: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/19.jpg)
19
Other UML Notations
Implementation diagrams– Component diagrams– Deployment diagrams– Introduced in lecture on System Design
• Object Constraint Language (OCL)– Introduced in lecture on Object Design
![Page 20: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/20.jpg)
20
UML Core Conventions
• Rectangles are classes or instances
• Ovals are functions or use cases
• Instances are denoted with an underlined names– myWatch:SimpleWatch– Joe:Firefighter
![Page 21: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/21.jpg)
21
UML Core Conventions
• Types are denoted with nonunderlined names– SimpleWatch– Firefighter
• Diagrams are graphs– Nodes are entities– Arcs are relationships between entities
![Page 22: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/22.jpg)
22
Use Case Diagram
• Used during requirements elicitation to represent external behavior
• Actors represent roles, that is, a type of user of the system
• Use cases represent a sequence of interaction for a type of functionality
• The use case model is the set of all use cases. It is a complete description of the functionality of the system & its environment
![Page 23: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/23.jpg)
23
A Use Case Diagram
Passenger
PurchaseTicket
![Page 24: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/24.jpg)
24
Actor
• An actor models an external entity which communicates with the system:– User– External system– Physical environment
• An actor has a unique name and an optional description.• Examples:
– Passenger: A person in the train– GPS satellite: Provides the system with GPS coordinates
![Page 25: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/25.jpg)
25
An Actor
Passenger
![Page 26: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/26.jpg)
26
Use Case
• A use case represents a class of functionality provided by the system as an event flow.
• A use case consists of:– Unique name– Participating actors– Entry conditions– Flow of events– Exit conditions– Special requirements
![Page 27: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/27.jpg)
27
A Use Case
PurchaseTicket
![Page 28: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/28.jpg)
28
Use Case Example
Name: Purchase Ticket
Participating actor: Passenger
Entry condition: • Passenger standing in front
of ticket distributor.• Passenger has sufficient
money to purchase ticket.
Exit condition:• Passenger has ticket.
Event flow:
1. Passenger selects the number of zones to be traveled.
2. Distributor displays the amount due.
3. Passenger inserts money, of at least the amount due.
4. Distributor returns change.
5. Distributor issues ticket.
![Page 29: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/29.jpg)
29
The <<extend>> Relationship
• <<extend>> relationships represent exceptional or seldom invoked cases.
• The exceptional event flows are factored out of the main event flow for clarity.
• Use cases representing exceptional flows can extend more than one use case.
• The direction of a <<extend>> relationship is to the extended use case
![Page 30: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/30.jpg)
30
<<extend>> Relationships
Passenger
PurchaseTicket
TimeOut
<<extend>>
NoChange
<<extend>>
OutOfOrder
<<extend>>
Cancel
<<extend>>
![Page 31: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/31.jpg)
31
The <<include>> Relationship
• An <<include>> relationship represents behavior that is factored out of the use case.
• An <<include>> represents behavior that is factored out for reuse, not because it is an exception.
• The direction of a <<include>> relationship is to the using use case (unlike <<extend>> relationships).
![Page 32: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/32.jpg)
32
Passenger
PurchaseSingleTicket
PurchaseMultiCard
NoChange
<<extend>>
Cancel
<<extend>>
<<include>>
CollectMoney
<<include>>
<<include>> Relationships
![Page 33: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/33.jpg)
33
Class Diagram
• Class diagrams represent the structure of the system.
• Class diagrams are used– during requirements analysis to model
problem domain concepts– during system design to model subsystems
and interfaces– during object design to model classes.
![Page 34: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/34.jpg)
34
A Class Diagram
Enumeration getZones()Price getPrice(Zone)
TariffSchedule
* *
Tripzone:Zoneprice:Price
![Page 35: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/35.jpg)
35
Class
• A class represent a concept.• A class encapsulates state (attributes)
& behavior (operations).• Each attribute has a type.• Each operation has a signature.• The class name is the only mandatory
information.
![Page 36: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/36.jpg)
36
A Class
zone2pricegetZones()getPrice()
TariffScheduleTable zone2priceEnumeration getZones()Price getPrice(Zone)
TariffSchedule
Name
Attributes
Operations
Signature
![Page 37: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/37.jpg)
37
Instance
• An instance represents a phenomenon.
• The name of an instance is underlined and can contain the class of the instance.
• The attributes are represented with their values.
![Page 38: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/38.jpg)
38
An Instance
zone2price = {{‘1’, .20},{‘2’, .40},{‘3’, .60}}
tariff_1974:TarifSchedule
![Page 39: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/39.jpg)
39
Actor, Class, & Instance
• Actor: – An entity outside the system to be modeled,
interacting with the system (“Pilot”)
• Class: – An abstraction modeling an entity in the problem
domain, inside the system to be modeled (“Cockpit”)
• Object: – A specific instance of a class (“Joe, the inspector”).
![Page 40: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/40.jpg)
40
Association
• Associations denote relationships between classes.
• The multiplicity of an association end denotes how many objects the source object can legitimately reference.
![Page 41: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/41.jpg)
41
An Association
Enumeration getZones()Price getPrice(Zone)
TarifSchedule
* pricezone
TripLeg
*
![Page 42: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/42.jpg)
42
Associations
1-to-1 association
1-to-many association
*
draw()
Polygon
x:Integery:Integer
Point1
Has-capital
name:String
Country
name:String
City11
![Page 43: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/43.jpg)
43
Aggregation
• An aggregation is a special case of association denoting a “consists of” hierarchy.
• The aggregate is the parent class, the components are the children class.
![Page 44: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/44.jpg)
44
Aggregations
1
Exhaust System
Muffler Tailpipe
0..2
![Page 45: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/45.jpg)
45
Composition
• A solid diamond denote composition,
• A strong form of aggregation
• Components cannot exist without the aggregate.
![Page 46: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/46.jpg)
46
Composition
3
TicketMachine
ZoneButton
![Page 47: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/47.jpg)
47
Generalization
• Generalization relationships denote inheritance between classes.
• The children classes inherit the attributes and operations of the parent class.
• Generalization simplifies the model by eliminating redundancy.
![Page 48: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/48.jpg)
48
Generalization
Button
ZoneButtonCancelButton
![Page 49: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/49.jpg)
49
From Problem Statement to Code
Problem Statement
A stock exchange lists many companies. Each company is identified by a ticker symbol
![Page 50: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/50.jpg)
50
From Problem Statement to Code
Problem Statement:
A stock exchange lists many companies. Each company is identified by a ticker symbol
![Page 51: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/51.jpg)
51
From Problem Statement to Code
Class Diagram
Java Codepublic class StockExchange { public Vector m_Company = new Vector();};public class Company { public int m_tickerSymbol; public Vector m_StockExchange = new Vector();};
*StockExchange
tickerSymbol
Company*lists
![Page 52: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/52.jpg)
52
UML Sequence Diagram• Used during requirements analysis
– To refine use case descriptions– to find additional objects (“participating objects”)
• Used during system design – to refine subsystem interfaces
• Classes are represented by columns• Messages are represented by arrows• Activations are represented by narrow
rectangles• Lifelines are represented by dashed lines
![Page 53: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/53.jpg)
53
A UML Sequence Diagram
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
PassengerTicketMachine
![Page 54: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/54.jpg)
54
UML Sequence Diagram with Nested Messages
• The source of an arrow indicates the activation which sent the message
• An activation is as long as all nested activations
![Page 55: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/55.jpg)
55
A UML Sequence Diagram with Nested Messages
selectZone()
price
PassengerZoneButton TarifSchedule Display
lookupPrice(selection)
displayPrice(price)
Dataflow
…to be continued...
![Page 56: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/56.jpg)
56
Sequence Diagram Observations
• UML sequence diagram represent behavior in terms of interactions.
• Complement the class diagrams which represent structure.
• Useful to find participating objects.
• Time consuming to build but worth the investment.
![Page 57: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/57.jpg)
57
Activity Diagram
• An activity diagram shows flow control within a system• An activity diagram is a special case of a state chart
diagram in which states are activities (“functions”)• Two types of states:
– Action state: • Cannot be decomposed any further
• Happens “instantaneously” with respect to the level of abstraction used in the model
– Activity state: • Can be decomposed further
• The activity is modeled by another activity diagram
![Page 58: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/58.jpg)
58
An Activity Diagram
HandleIncident
DocumentIncident
ArchiveIncident
![Page 59: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/59.jpg)
59
Activity Diagram: Modeling Decisions
OpenIncident
NotifyPolice Chief
NotifyFire Chief
AllocateResources
[fire & highPriority]
[not fire & highPriority]
[lowPriority]
![Page 60: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/60.jpg)
60
Activity Diagram: Modeling Concurrency
• Synchronization of multiple activities
• Splitting the flow of control into multiple threads
![Page 61: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/61.jpg)
61
Activity Diagram: Modeling Concurrency
SynchronizationSplitting
ArchiveIncident
OpenIncident
DocumentIncident
AllocateResources
CoordinateResources
![Page 62: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/62.jpg)
62
Activity Diagrams: Swimlanes
• Actions may be grouped into swimlanes
• Denote the object or subsystem that implements the actions.
![Page 63: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/63.jpg)
63
Activity Diagrams: Swimlanes
ArchiveIncident
Dispatcher
FieldOfficer
OpenIncident
DocumentIncident
AllocateResources
CoordinateResources
![Page 64: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/64.jpg)
64
Summary• UML provides a wide variety of notations for
representing many aspects of software development– Powerful, but complex language– Can be misused to generate unreadable models– Can be misunderstood when using too many exotic
features
• We concentrate only on a few notations:– Functional model: use case diagram– Object model: class diagram– Dynamic model: sequence diagrams, statechart and
activity diagrams
![Page 65: 1 Modeling with UML CMPE 131 Fall 2003. 2 Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams](https://reader036.vdocument.in/reader036/viewer/2022062804/56649d785503460f94a5a670/html5/thumbnails/65.jpg)
65
References
• M. Fowler, UML Distilled, 2nd edition, Addison Wesley, 2000.
• G. Booch, J. Rumbaugh, and I. Jacobson, The Unified Modeling Language User Guide, Addison Wesley, 1999.
• B. Bruegge and A. Dutoit, Object-Oriented Software Engineering Using UML, Patterns, and Java, 2nd edition, Prentice Hall, 2004