using uml, patterns, and java object-oriented software engineering more on uml note: slides are...
TRANSCRIPT
Usi
ng U
ML
, Pat
tern
s, a
nd J
ava
Ob
ject
-Ori
ente
d S
oftw
are
En
gin
eeri
ng
More on UML
Note: Slides are adapted by Linda Sherrell from the Software Engineering text as noted to the left.
The text is by Bernd Brugge and Alan Dutoit
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
Class Diagrams
Class diagrams represent the structure of the system. Used
during requirements analysis to model problem domain concepts Called the Domain Model during the Requirements Workflow
during system design to model subsystems and interfaces during object design to model classes.
Enumeration getZones()Price getPrice(Zone)
TarifSchedule
* *
Tripzone:Zone
Price: Price
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
Classes
A class represent 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.
zone2pricegetZones()getPrice()
TarifSchedule
Table zone2priceEnumeration getZones()Price getPrice(Zone)
TarifSchedule
Name
Attributes
Operations
Signature
TarifSchedule
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
PriceZone
Associations
Associations denote relationships between classes. The multiplicity of an association end denotes how many objects the source
object can legitimately reference.
Enumeration getZones()Price getPrice(Zone)
TarifSchedule TripLeg
* *
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
1-to-1 and 1-to-many Associations
Country
name:String
City
name:String
Has-capital
Polygon
draw()
Point
x: Integer
y: Integer
One-to-one association
One-to-many association
*
1 11
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
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 Company
tickerSymbolLists
**
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
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.
A solid diamond denotes composition, a strong form of aggregation where components cannot exist without the aggregate. (Bill of Material)
TicketMachine
ZoneButton3
Exhaust system
Muffler
diameter
Tailpipe
diameter
1 0..2
Exhaust system
Muffler
diameter
Tailpipe
diameter
1 0..2
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
Inheritance
The children classes inherit the attributes and operations of the parent class.
Inheritance simplifies the model by eliminating redundancy.
Button
ZoneButtonCancelButton
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
Object Modeling in Practice: A Banking System
Account
Betrag
Deposit()Withdraw()GetBalance()
Customer
NameCustomerId
CustomerIdAccountId
AccountIdBank
Name
1) Find New Objects
2) Iterate on Names, Attributes and Methods
3) Find Associations between Objects
Has
4) Label the assocations5) Determine the multiplicity of the assocations
*
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
Practice Object Modeling: Iterate, Categorize!
Customer
Name
CustomerId()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountId
AccountId
Bank
Name Has**
SavingsAccount
Withdraw()
CheckingAccount
Withdraw()
MortgageAccount
Withdraw()
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
Packages
A package is a UML mechanism for organizing elements into groups (usually not an application domain concept)
Packages are the basic grouping construct with which you may organize UML models to increase their readability.
A complex system can be decomposed into subsystems, where each subsystem is modeled as a package
DispatcherInterface
Notification IncidentManagement
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
UML Sequence diagram: Terminology
:LCDDisplay
blinkHours()
blinkMinutes()
refresh()
commitNewTime()
:Time
incrementMinutes()
stopBlinking()
:Watch
pressButton1()
pressButton2()
pressButtons1And2()
pressButton1()
:WatchUser
Object
Message
Activation
Sequence diagrams represent the behavior as interactions
Actor
Lifeline
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
UML sequence diagrams
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
rectangles Messages are represented by
arrows Activations are represented by
narrow rectangles Lifelines are represented by
dashed lines
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
Passenger TicketMachine
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
Nested messages
The source of an arrow indicates the activation which sent the message An activation is as long as all nested activations Horizontal dashed arrows indicate data flow Vertical dashed lines indicate lifelines
selectZone()
Passenger ZoneButton TarifSchedule Display
lookupPrice(selection)
displayPrice(price)
price
Dataflow
…to be continued...
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
Creation and destruction
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.
Passenger ChangeProcessor
…continued from previous slide...
Ticket
createTicket(selection)
free()
Creation
Destruction
print()
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Iterations and Conditions
See Larman text: pp. 230-236 Terminology
loop – iteration opt – conditional (if) alt – conditional (if/else) ref – frame tag for another sequence diagram sd – sequence diagram referred to in ref
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
Sequence Diagram Summary
UML sequence diagram represent behavior in terms of interactions.
Useful to find missing objects. Time consuming to build but worth the investment. Complement the class diagrams (which represent structure).