object-oriented systems development:developmentsun.csim.scu.edu.tw/~chiang/course/4oot/chap5.pdf ·...
TRANSCRIPT
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Chapter 5:Unified Modeling Language
Object-Oriented SystemsObject-Oriented SystemsDevelopmentDevelopment:Using the Unified ModelingUsing the Unified ModelingLanguageLanguage
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Goals
•Modeling.•Unified modeling language.–Class diagram.–Use case diagram.– Interaction diagrams.•Sequence diagram.•Collaboration diagram.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Goals (Con’t)
– Statechart diagram.–Activity diagram.– Implementation diagrams.•Component diagram.•Deployment diagram.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Introduction•A model is an abstract representation
of a system, constructed tounderstand the system prior tobuilding or modifying it.•Most of the modeling techniques
involve graphical languages.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Static or Dynamic Models
•Models can represent– static or– dynamic situations.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Static Model•A static model can be viewed as a
"snapshot" of a system'sparameters at rest or at a specificpoint in time.•The classes’ structure
and their relationshipsto each other frozenin time are examples ofstatic models.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Dynamic Model• Is a collection of procedures or
behaviors that, taken together,reflect the behavior of a systemover time.•For example, an order interacts
with inventory to determineproduct availability.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Why Modeling?•Turban cites the following
advantages:•Models make it easier to express
complex ideas.•For example, an architect
builds a model tocommunicate ideasmore easily to clients.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Advantages of Modeling (Con’t)
•Models reduce complexity byseparating those aspects that areunimportant from those that areimportant.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Advantages of Modeling (Con’t)•Models enhance learning.•The cost of the modeling analysis
is much lower than the cost ofsimilar experimentationconducted with a real system.•Manipulation of the model
(changing variables) is mucheasier than manipulating a realsystem.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Modeling Key Ideas•A model is rarely correct on the
first try.•Always seek the advice and
criticism of others.•Avoid excess model revisions, as
they can distort the essence ofyour model. Let simplicity andelegance guide you through the process.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
The Unified Modeling Language(UML)
•The unified modeling language(UML) is a language for specifying,constructing, visualizing, anddocumenting the software systemand its components.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML DiagramsThe UML defines nine graphical
diagrams:1. Class diagram (static)2. Use-case diagram3. Behavior diagrams (dynamic):– 3.1. Interaction diagram:•3.1.1. Sequence diagram•3.1.2. Collaboration diagram
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
– 3.2. Statechart diagram– 3.3. Activity diagram
4. Implementation diagram:4.1. Component diagram4.2. Deployment diagram
UML Diagrams
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Class Diagram,•The UML class diagram is the
main static analysis diagram.•Class diagrams show the static
structure of the model.•Class diagram is collection of
static modeling elements, such asclasses and their relationships.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Class Notation
Boeing 737length: meterfuelCapacity: Galdoors: int
lift ()break ()
Boeing 737
Boeing 737
length: meterfuelCapacity: Galdoors: int
• In class notation, either or both theattributes and operation compartmentsmay be suppressed.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Class Interface Notation• Class interface notation is used to
describe the externally visiblebehavior of a class.
• For example, an operation with apublic visibility.
Person BankAccount
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Binary Association Notation• A binary association is drawn as a
solid path connecting two classes orboth ends may be connected to thesame class.
Company PersonworksFor
employer employee
Person
marriedTo
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Association Role•A simple association—the
technical term for it is binaryassociation—is drawn as a solidline connecting two class symbols.•The end of an association, where
it connects to a class, shows theassociation role.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Association Notation• In the UML, association is represented
by an open arrow.
BankAccount Person
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Qualifier• A qualifier is an association attribute.
For example, a person object may beassociated to a Bank object.
• An attribute of this association is theaccount#.
• The account# is thequalifier of thisassociation.
Bank
Person
account#
0..1
*
.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Multiplicity•Multiplicity specifies the range of
allowable associated classes.• It is given for roles within
associations, parts withincompositions, repetitions, and otherpurposes.• lower bound .. upper bound.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
OR Association• An OR association indicates a
situation in which only one of severalpotential associations may besubstantiated at one time for anysingle object.
Person
Company
Car {or}
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Association Class• An association class is an association
that also has class properties.• An association class is shown as a class
symbol attached by a dashed line to anassociation path.
WorksFor
Personemployer employee
Company
salary
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
N-Ary Association• An n-ary association is an association
among more than two classes.• Since n-ary association is more
difficult to understand, it is better toconvert an n-ary association to binaryassociation.
GradeBook
Studentclass
Class
gradeexamlab
Year
semester
*
*
*student
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Aggregation
• Aggregation is a form of association.• A hollow diamond is attached to the end
of the path to indicate aggregation.
Playerclass
Team1 *consistOf
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Composition• Composition, also known as the a-
part-of, is a form of aggregation withstrong ownership to represent thecomponent of a complex object.
• The UML notation for composition is asolid diamond at the end of a path.
Car
4Wheel Light Door Engine
4,10 2,5
1
1
11
WheelLightDoorEngine
44,102,5
1
CarWheel
DoorEngine
44,102,5
1
Car
1
nested composition
graphical composition
Light
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Generalization•Generalization is the relationship
between a more general class and amore specific class.
•Generalization is displayed as directedline with a closed, hollowarrowhead at thesuperclass end.
Vehicle
Bus Truck Car
Boeing 737
BoeingAirplane
Boeing 757 Boeing 767
Shared target style
Separate target style
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Use-Case Diagram•The description of a use case
defines what happens in thesystem when the use case isperformed.• In essence, the use-case model
defines the outside (actors) andinside (use case) of the system'sbehavior.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Use-Case Diagram (Con’t)
Help Desk
Making a call
Take the call
Do research
Return a call
Client Operator
Supportrepresentative
• A use-case diagram is a graph of actors, a setof use cases enclosed by a system boundary,communication (participation) associationsbetween the actors and the use cases, andgeneralization among the use cases.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Actor Notations• The three representations of an actor
are equivalent.
<< actor>> << actor>>Customer Customer Customer
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Use-Case Diagram (Con’t)
•These relationships are shown ina use-case diagram:–Communication.–Uses.– Extends.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Behavior or Dynamic Diagrams
• Interaction diagrams:– Sequence diagrams–Collaboration diagrams
•Statechart diagrams•Activity diagrams
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Interaction Diagrams• Interaction diagrams describe how
groups of objects collaborate toget the job done.• Interaction diagrams capture the
behavior of a single use case,showing the pattern of interactionamong objects.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Sequence Diagram• Sequence diagrams are an easy and
intuitive way of describing thebehavior of a system.
• A sequence diagram shows aninteraction arranged in a timesequence. Telephone Call
DialTone
Exchange ReceiverCaller
OffHook
RingTone
Dial Number
Talk
OffHooke
OnHook
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Collaboration Diagram• A collaboration diagram represents a
set of objects related in a particularcontext, and the exchange of theirmessages to achieve a desiredoutcome. Telephone Call
2: DialTone
Exchange
Receiver
Caller
5: OffHook
4: RingTone
3: Dial Number
Talk
1: OffHooke
6: OnHook
Object Message
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Collaboration Diagram(Con’t)
Telephone Call
2.1: DialTone
Exchange
Receiver
Caller
3.1: OffHook
2.2: RingTone
1.2: Dial Number
Talk
1.1: OffHooke
4.1: OnHook
Object Message
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Statechart Diagram•A statechart diagram (also
called a state diagram) showsthe sequence of states that anobject goes through during itslife in response to outsidestimuli and messages.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Idlelift receiver and get dial tone
State
Substates
Dialing
Start Dialentry and start dialogexit/ stop dial tone entry and number.append(n)
digit(n)
number.siValid()
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Activity Diagram•An activity diagram is a
variation or special case of astate machine, in which thestates are activitiesrepresenting the performanceof operations and thetransitions are triggered by thecompletion of the operations.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Activity Diagram (Con’t) Prepareincomingdocument
s
Indexdocuments
CompleteRequest
Make electronicfile
Check data forlifeinsurance
Draw up contract
Mortgage-deed
Calculate dataforconstructionmortgage
Pay provisiontoinsurance
agent
Draw up insurancepolicy
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Activity Decision
Calculate payroll[hours < =40]
[hours > 40]
Normal payroll
Overtime, get authoriation
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Swimlanes. Prepare incoming
documents
Index documents
Completerequest
Make electronicfile
Check data for lifeinsurance
Draw up conceptmortgage-deed
Calculate data forconstruction
mortgagePay provision toinsurance agent
Draw up insurancepolicy
office clerk InsuranceAgent Loanofficer
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Implementation diagrams•These diagrams show the
implementation phase ofsystems development.•Such as the source code
structure and the run-timeimplementation structure.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Implementation diagrams(Con’t)
•There are two types ofimplementation diagrams:–Component diagrams show the
structure of the code itself.–Deployment diagrams show the
structure of the run-time system.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Component diagrams
U I
UpdateAccess
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Deployment Diagram
Node 1: AdminServer
Node 2: John PC
U I
UpdateAccess
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Model Management: Package•A package is a grouping of
model elements.•Packages themselves may
contain other packages.•A package may contain both
subordinate packages andordinary model elements.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
A Package and Its Contents
GradeBook
Studentclass
Class
gradeexamlab
Year
semester
*
*
*student
GradeNoteBook
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
A Package and Its Dependencies
Bank
Business Model
Customer
Clients
Account
Checking Saving
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Model Constraints and Comments• Constraints are assumptions or
relationships among model elementsspecifying conditions andpropositions that must be maintainedas true otherwise the system describedby the model would be invalid.
Person Department
WorkFor* *
ManagerOf
{subset}
1 1
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Note• A note is a graphic symbol containing
textual information; it also couldcontain embedded images.
Representsan incorporatedentity
Person Companyemployee employer
Static models &revision levelsreleased yesterday
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Stereotype• Stereotypes represent a built-in
extendibility mechanism of the UML.• User-defined extensions of the UML
are enabled through the use ofstereotypes and constraints.
Copy
NumberOfCopy
Flow Copy
NumberOfCopy
Flow
makeCopy makeCopy
Copy
NumberOfCopy
makeCopy
Copy
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Meta-Model•A meta-model is a model of
modeling elements.•The purpose of the UML meta-
model is to provide a single,common, and definitivestatement of the syntax andsemantics of the elements ofthe UML.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
UML Meta-Model (Con’t)Relationship
Generalization Association
1
Association Role
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Summary•A model is a simplified
representation of reality.•The unified modeling
language (UML) wasdeveloped by Booch, Jacobson,and Rumbaugh andencompasses the unification oftheir modeling notations.
Object-Oriented Systems Development Bahrami ? Irwin/ McGraw-Hill
Summary (Con’t)
•UML consists of the followingdiagrams:–Class diagram.–Use case diagram.– Sequence diagram.–Collaboration diagram.