Ch02lect1 ud
-
Upload
ahmet-balkan -
Category
Documents
-
view
1.110 -
download
0
Transcript of Ch02lect1 ud
![Page 1: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/1.jpg)
Usi
ng U
ML
, Pat
tern
s, a
nd J
ava
Ob
ject
-Ori
ente
d S
oftw
are
En
gin
eeri
ng Chapter 2,
Modeling with UML
![Page 2: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/2.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
Overview: modeling with UML
What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams
![Page 3: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/3.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
What is modeling?
Modeling consists of building an abstraction of reality. Abstractions are simplifications because:
They ignore irrelevant details and They only represent the relevant details.
What is relevant or irrelevant depends on the purpose of the model.
![Page 4: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/4.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
Example: street map
![Page 5: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/5.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
Why model software?
Why model software?
Software is getting increasingly more complex Windows XP > 40 million lines of code A single programmer cannot manage this amount of code in its
entirety.
Code is not easily understandable by developers who did not write it
We need simpler representations for complex systems Modeling is a means for dealing with complexity
![Page 6: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/6.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
Systems, Models and Views
A model is an abstraction describing a subset of a system A view depicts selected aspects of a model A notation is a set of graphical or textual rules for depicting views Views and models of a single system may overlap each other
Examples: System: Aircraft Models: Flight simulator, scale model Views: All blueprints, electrical wiring, fuel system
![Page 7: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/7.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
Systems, Models and Views
SystemView 1
Model 2View 2
View 3
Model 1
Aircraft
Flightsimulator
Scale Model
Blueprints
Electrical Wiring
![Page 8: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/8.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
Models, Views and Systems (UML)
System Model View**
Depicted byDescribed by
Airplane: System
Blueprints: View Fuel System: View Electrical Wiring: View
Scale Model: Model Flight Simulator: Model
![Page 9: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/9.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
Application and 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 10: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/10.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
Object-oriented Modeling
Application Domain (Phenomena)
Solution Domain (Phenomena)
System Model (Concepts) System Model (Concepts)
Aircraft TrafficController
FlightPlanAirport
MapDisplay
FlightPlanDatabase
SummaryDisplay
TrafficControl
TrafficControl
UML Package
(Analysis) (Design)
![Page 11: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/11.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
What is UML?
UML (Unified Modeling Language) Nonproprietary standard for modeling software systems, OMG Convergence of notations used in object-oriented methods
OMT (James Rumbaugh and collegues) Booch (Grady Booch) OOSE (Ivar Jacobson)
Current Version: UML 2.2 Information at the OMG portal http://www.uml.org/
Commercial tools: Rational (IBM),Together (Borland), Visual Architect (business processes, BCD)
Open Source tools: ArgoUML, StarUML, Umbrello
Commercial and Opensource: PoseidonUML (Gentleware)
![Page 12: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/12.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
UML: First Pass
You can model 80% of most problems by using about 20% UML
We teach you those 20%
80-20 rule: Pareto principle http://www.ephorie.de/hindle_pareto-prinzip.htm
![Page 13: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/13.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
UML First Pass
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.
![Page 14: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/14.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
UML Core Conventions
All UML Diagrams denote graphs of nodes and edges Nodes are entities and drawn as rectangles or ovals Rectangles denote classes or instances Ovals denote functions
• Names of Classes are not underlined• SimpleWatch• Firefighter
• Names of Instances are underlined• myWatch:SimpleWatch• Joe:Firefighter
• An edge between two nodes denotes a relationship between the corresponding entities
![Page 15: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/15.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
UML first pass: Use case diagrams
Use case diagrams represent the functionality of the systemfrom user’s point of view
Actor.
Use Case
System boundary
Classifier
![Page 16: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/16.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Historical Remark: UML 1 used packages
WatchUser
Actor
Use casePackage Watch
Use case diagrams represent the functionality of the systemfrom user’s point of view
ReadTime
SetTime
ChangeBattery
WatchRepairPerson
![Page 17: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/17.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
UML first pass: Class diagrams
ClassAssociation
Multiplicity
Class diagrams represent the structure of the system
21 1
11
11
2
SimpleWatch
Display Battery TimePushButton
![Page 18: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/18.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18
UML first pass: Class diagrams
12
push()release()
1
1
blinkIdxblinkSeconds()blinkMinutes()blinkHours()stopBlinking()referesh()
LCDDisplay BatteryLoad
1
2
1
TimeNow
1
Watch
Operations
statePushButton
Attribute
Class diagrams represent the structure of the system
ClassAssociation
Multiplicity
![Page 19: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/19.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19
Message
UML first pass: Sequence diagram
:Time :Watch:WatchUser
Object
Activation
Sequence diagrams represent the behavior of a system as messages (“interactions”) between different objects
Actor
pressButton1()
Lifeline
blinkHours()
pressButton2()incrementMinutes()
:LCDDisplay
pressButton1and2()commitNewTime()
stopBlinking()
refresh()
pressButton1()blinkMinutes()
![Page 20: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/20.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
UML first pass: Statechart diagrams
State
Initial state
Final state
Transition
Event
Represent behavior of a single object with interesting dynamic behavior.
button1&2Pressed
button1Pressed
button2Pressed
button2Pressed
button2Pressed
button1Pressed
button1&2Pressed IncrementMinutes
IncrementHours
BlinkHours
BlinkSeconds
BlinkMinutes
IncrementSeconds
StopBlinking
![Page 21: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/21.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
Other UML Notations
UML provides many other notations, for example Deployment diagrams for modeling configurations
Useful for testing and for release management
We introduce these and other notations as we go along in the lectures OCL: A language for constraining UML models
![Page 22: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/22.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
What should be done first? Coding or Modeling?
It all 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.
![Page 23: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/23.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
UML Basic Notation Summary
UML provides a wide variety of notations for modeling many aspects of software systems
Today we concentrated on a few notations: Functional model: Use case diagram Object model: Class diagram Dynamic model: Sequence diagrams, statechart
![Page 24: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/24.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
Outline of this Class
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.
![Page 25: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/25.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
UML Basic Notation: First Summary
UML provides a wide variety of notations for modeling many aspects of software systems
In the first lecture we concentrated on: Functional model: Use case diagram Object model: Class diagram Dynamic model: Sequence diagrams, statechart
Now we go into a little bit more detail…
![Page 26: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/26.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
UML Use Case Diagrams
An Actor represents a role, that is, a type of user of the system
Passenger
PurchaseTicket
Used during requirements elicitation and analysis to represent external behavior (“visible from the outside of the system”)
Use case model:The set of all use cases that completely describe the functionality of the system.
A use case represents a class of functionality provided by the system
![Page 27: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/27.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
Actors
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
Examples: Passenger: A person in the train GPS satellite: An external system that provides
the system with GPS coordinates.
Passenger
Name
Optional Description
![Page 28: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/28.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
Use Case• 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.
PurchaseTicket
![Page 29: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/29.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
Textual Use Case Description Example
1. Name: Purchase ticket
2. Participating actor: Passenger
3. Entry condition: Passenger stands in front of
ticket distributor Passenger has sufficient
money to purchase ticket
4. Exit condition: Passenger has ticket
5. Flow of events:1. Passenger selects the
number of zones to be traveled
2. Ticket 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.
PassengerPurchaseTicket
![Page 30: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/30.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
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.
![Page 31: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/31.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
The <<extends>> Relationship <<extends>> relationships model
exceptional or seldom invoked cases 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.
Passenger
PurchaseTicket
TimeOut
<<extends>>
NoChange
<<extends>>OutOfOrder
<<extends>>
Cancel
<<extends>>
![Page 32: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/32.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
The <<includes>> Relationship
<<includes>> relationship represents common functionality needed in more than one use case
<<includes>> behavior is factored out for reuse, not because it is an exception
The direction of a <<includes>> relationship is to the using use case (unlike the direction of the <<extends>> relationship).
Passenger
PurchaseSingleTicket
PurchaseMultiCard
<<includes>>
CollectMoney
<<includes>>
NoChange
<<extends>>
Cancel
<<extends>>
Cancel
<<extends>>
![Page 33: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/33.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
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.
Table zone2priceEnumeration getZones()Price getPrice(Zone)
TarifSchedule
* *
Tripzone:Zone
Price: Price
![Page 34: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/34.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34
Classes
A class represents a concept A class encapsulates state (attributes) and behavior (operations)
Table zone2priceEnumeration getZones()Price getPrice(Zone)
TarifSchedule
zone2pricegetZones()getPrice()
TarifSchedule
Name
Attributes
Operations
Signature
TarifSchedule
The class name is the only mandatory information
Each attribute has a typeEach operation has a signature
Type
![Page 35: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/35.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 35
Instances
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)
zone2price = {{‘1’, 0.20},{‘2’, 0.40},{‘3’, 0.60}}
tarif2006:TarifSchedulezone2price = {{‘1’, 0.20},{‘2’, 0.40},{‘3’, 0.60}}
:TarifSchedule
![Page 36: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/36.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 36
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”).
![Page 37: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/37.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 37
Associations
Associations denote relationships between classes
PriceZone
Enumeration getZones()Price getPrice(Zone)
TarifSchedule TripLeg
* *
The multiplicity of an association end denotes how many objects the instance of a class can legitimately reference.
![Page 38: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/38.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 38
1-to-1 and 1-to-many Associations
1-to-1 association
1-to-many association
Polygon
draw()
Point
x: Integer
y: Integer
*
Country
name:String
City
name:String
11
![Page 39: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/39.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 39
Many-to-Many Associations
StockExchange
Company
tickerSymbol**
![Page 40: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/40.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 40
From Problem Statement To Object Model
Class Diagram:
StockExchange Company
tickerSymbolLists
**
Problem Statement: A stock exchange lists many companies. Each company is uniquely identified by a ticker symbol
![Page 41: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/41.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 41
From Problem Statement to Code
Problem Statement : A stock exchange lists many companies. Each company is identified by a ticker symbol
Class Diagram:
private Vector m_Company = new Vector();
public int m_tickerSymbol; private Vector m_StockExchange = new Vector();
public class StockExchange{
};
public class Company{
};
Java Code
StockExchange Company
tickerSymbolLists **
Associationsare mapped to
Attributes!
![Page 42: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/42.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 42
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 classes
Exhaust system
Muffler
diameter
Tailpipe
diameter
1 0..2
TicketMachine
ZoneButton3
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”)
![Page 43: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/43.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 43
Qualifiers
Qualifiers can be used to reduce the multiplicity of an association
DirectoryFile
filename
Without qualification
1 *
With qualification
0..1Directory File
1filename
![Page 44: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/44.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 44
Qualification: Another Example
*StockExchangeCompanyLists *tickerSymbol
1
StockExchange
Company
tickerSymbolLists **
![Page 45: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/45.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 45
Inheritance
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.
Button
ZoneButtonCancelButton
![Page 46: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/46.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 46
Packages
Packages help you to organize UML models to increase their readability
We can use the UML package mechanism to organize classes into subsystems
Any complex system can be decomposed into subsystems, where each subsystem is modeled as a package.
Account
CustomerBank
![Page 47: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/47.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 47
Object Modeling in Practice
Class Identification: Name of Class, Attributes and Methods
Is Foo the right name?
Foo
Amount
CustomerId
Deposit()Withdraw()GetBalance()
![Page 48: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/48.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 48
Object Modeling in Practice: Brainstorming
Foo
Amount
CustomerId
Deposit()Withdraw()GetBalance()
Account
Amount
CustomerId
Deposit()Withdraw()GetBalance()Is Foo the right name?
“Dada”
Amount
CustomerId
Deposit()Withdraw()GetBalance()
![Page 49: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/49.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 49
Object Modeling in Practice: More classes
Account
Amount
Deposit()Withdraw()GetBalance()
Customer
NameCustomerId
CustomerIdAccountIdBank
Name
1) Find New Classes
2) Review Names, Attributes and Methods
![Page 50: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/50.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 50
Object Modeling in Practice: Associations
Account
Amount
Deposit()Withdraw()GetBalance()
Customer
NameCustomerId
CustomerIdAccountId
AccountIdBank
Name
1) Find New Classes
2) Review Names, Attributes and Methods
3) Find Associations between Classes
owns
4) Label the generic assocations
6) Review associations
*2
*?has
5) Determine the multiplicity of the assocations
![Page 51: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/51.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 51
Practice Object Modeling: Find Taxonomies
SavingsAccount
Withdraw()
CheckingAccount
Withdraw()
MortgageAccount
Withdraw()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountId
AccountId
Customer
Name
CustomerId()
Has*Bank
Name*
![Page 52: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/52.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 52
Practice Object Modeling: Simplify, Organize
SavingsAccount
Withdraw()
CheckingAccount
Withdraw()
MortgageAccount
Withdraw()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountId
AccountIdShow Taxonomies
separately
![Page 53: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/53.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 53
Practice Object Modeling: Simplify, Organize
Customer
Name
CustomerId()
Account
Amount
Deposit()Withdraw()GetBalance()
CustomerIdAccountId
AccountId
Bank
Name Has**
Use the 7+-2 heuristics
or better 5+-2!
![Page 54: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/54.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 54
Sequence Diagrams
Used during analysis To refine use case descriptions to find additional objects
(“participating objects”) Used during system design
to refine subsystem interfaces Instances are represented by
rectangles. Actors by sticky figures Lifelines are represented by dashed
lines Messages are represented by arrows Activations are represented by narrow
rectangles.
selectZone()
pickupChange()
pickUpTicket()
insertCoins()
TicketMachinePassenger
Focus on control flow
Messages ->Operations on
participating Object
zone2priceselectZone()insertCoins()pickupChange()pickUpTicket()
TicketMachine
![Page 55: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/55.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 55
Sequence Diagrams can also model the Flow of Data
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
Passenger
selectZone()
ZoneButton TarifSchedule Display
lookupPrice(selection)
displayPrice(price)
price
Dataflow
…continued on next slide...
![Page 56: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/56.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 56
Sequence Diagrams: Iteration & Condition
Iteration is denoted by a * preceding the message name Condition is denoted by boolean expression in [ ] before the message
name
PassengerChangeProcessor
insertChange(coin)
CoinIdentifier Display CoinDrop
displayPrice(owedAmount)
lookupCoin(coin)
price
[owedAmount<0] returnChange(-owedAmount)
Iteration
Condition
…continued on next slide...
…continued from previous slide...
*
![Page 57: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/57.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 57
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.
PassengerChangeProcessor
…continued from previous slide...
Ticket
createTicket(selection)
free()
Creation of Ticket
Destruction of Ticket
print()
![Page 58: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/58.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 58
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).
![Page 59: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/59.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 59
Activity Diagrams
An activity diagram is a special case of a state chart diagram The states are activities (“functions”) An activity diagram is useful to depict the workflow in a
system
HandleIncident
DocumentIncident
ArchiveIncident
![Page 60: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/60.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 60
Activity Diagrams allow to model Decisions
OpenIncident
NotifyPolice Chief
NotifyFire Chief
AllocateResources
[fire & highPriority]
[not fire & highPriority]
[lowPriority]
Decision
![Page 61: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/61.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 61
Activity Diagrams can model Concurrency
Synchronization of multiple activities Splitting the flow of control into multiple threads
OpenIncident
AllocateResources
CoordinateResources
DocumentIncident
ArchiveIncident
SynchronizationSplitting
![Page 62: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/62.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 62
Activity Diagrams: Grouping of Activities
Activities may be grouped into swimlanes to denote the object or subsystem that implements the activities.
OpenIncident
AllocateResources
CoordinateResources
DocumentIncident
ArchiveIncident
Dispatcher
FieldOfficer
![Page 63: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/63.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 63
Activity Diagram vs. Statechart Diagram
HandleIncident
DocumentIncident
ArchiveIncident
Active Inactive Closed ArchivedIncident-Handled
Incident-Documented
Incident-Archived
Statechart Diagram for IncidentFocus on the set of attributes of a single abstraction (object, system)
Activity Diagram for Incident
(Focus on dataflow in a system)
TriggerlesstransitionCompletion of activity
causes state transition
Event causesstate transition
![Page 64: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/64.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 64
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
![Page 65: Ch02lect1 ud](https://reader036.fdocuments.in/reader036/viewer/2022062404/554a0158b4c905507a8b4f0c/html5/thumbnails/65.jpg)
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 65
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, 2nd
edition, 2005
Commercial UML tools Rational Rose XDE for Java
http://www-306.ibm.com/software/awdtools/developer/java/
Together (Eclipse, MS Visual Studio, JBuilder) http://www.borland.com/us/products/together/index.html
Open Source UML tools http://java-source.net/open-source/uml-modeling ArgoUML,UMLet,Violet, …