2008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage 11
Introduction to Introduction to Unified Modeling LanguageUnified Modeling Language
(UML) – Part One(UML) – Part One
Ku-Yaw ChangKu-Yaw [email protected]@mail.dyu.edu.tw
Assistant ProfessorAssistant ProfessorDepartment of Computer Science and Information EngineeringDepartment of Computer Science and Information Engineering
Da-Yeh UniversityDa-Yeh University
222008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Importance of modelingImportance of modeling
What is a model?What is a model? A simplification of realityA simplification of reality
Why do we model?Why do we model? Better understand the system we are Better understand the system we are
developingdeveloping
332008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Four aimsFour aims
ModelsModels Help us to visualize a system as it is or as we Help us to visualize a system as it is or as we
want it to bewant it to be Permit us to specify the structure or behavior Permit us to specify the structure or behavior
of a systemof a system Give us a template that guides us in Give us a template that guides us in
constructing a systemconstructing a system Document the decisions we have madeDocument the decisions we have made
442008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Unified Modeling Language (UML)Unified Modeling Language (UML)
A standard language for A standard language for VisualizingVisualizing SpecifyingSpecifying ConstructingConstructing DocumentingDocumenting
the artifacts of a software-intensive systemthe artifacts of a software-intensive system
Official web siteOfficial web site http://www.uml.org/http://www.uml.org/ Current version: 2.1Current version: 2.1
552008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Diagrams in the UMLDiagrams in the UML
A diagramA diagram Graphical presentation of a set of elementsGraphical presentation of a set of elements
Rendered as a connected graph of vertices Rendered as a connected graph of vertices (things) and arcs (relationships)(things) and arcs (relationships)
A projection into a systemA projection into a systemVisualize a system from different perspectivesVisualize a system from different perspectives
662008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Diagrams in the UMLDiagrams in the UML
UML 2.0 defines 13 diagrams, divided into UML 2.0 defines 13 diagrams, divided into two general sets:two general sets: StructuralStructural modeling diagrams modeling diagrams
Define the static architecture of a modelDefine the static architecture of a model Classes, objects, interfaces and physical componentsClasses, objects, interfaces and physical components
Model the relationships and dependencies Model the relationships and dependencies between elementsbetween elements
BehavioralBehavioral modeling diagrams modeling diagramsCapture the varieties of interaction and Capture the varieties of interaction and instantaneous state within a model as it 'executes' instantaneous state within a model as it 'executes' over time. over time.
772008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Structural diagrams (1/2)Structural diagrams (1/2)
Package diagramsPackage diagrams Divide the model into logical containers or 'packages' Divide the model into logical containers or 'packages'
and describe the interactions between them at a high and describe the interactions between them at a high levellevel
Class or Structural diagramsClass or Structural diagrams Define the basic building blocks of a model: the types, Define the basic building blocks of a model: the types,
classes and general materials that are used to classes and general materials that are used to construct a full modelconstruct a full model
Object diagramsObject diagrams Show how instances of structural elements are Show how instances of structural elements are
related and used at run-time. related and used at run-time.
882008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Structural diagrams (2/2)Structural diagrams (2/2)
Composite structure diagramsComposite structure diagrams Provide a means of layering an element's structure Provide a means of layering an element's structure
and focusing on inner detail, construction and and focusing on inner detail, construction and relationshipsrelationships
Component diagramsComponent diagrams Model higher level or more complex structures, Model higher level or more complex structures,
usually built up from one or more classes, and usually built up from one or more classes, and providing a well defined interfaceproviding a well defined interface
Deployment diagramsDeployment diagrams Show the physical disposition of significant artifacts Show the physical disposition of significant artifacts
within a real-world setting within a real-world setting
992008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Behavioral diagrams (1/2)Behavioral diagrams (1/2)
Use case diagramsUse case diagrams Model user/system interactions.Model user/system interactions. Define behavior, requirements and constraints in the Define behavior, requirements and constraints in the
form of scripts or scenariosform of scripts or scenarios
Activity diagramsActivity diagrams Define basic program flowDefine basic program flow Capture the decision points and actions within any Capture the decision points and actions within any
generalized processgeneralized process
State machine diagramsState machine diagrams Understanding the instant condition or "run state" of a Understanding the instant condition or "run state" of a
model when it executesmodel when it executes
10102008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Behavioral diagrams (2/2)Behavioral diagrams (2/2)
Communication diagramsCommunication diagrams Show the network and sequence of messages or Show the network and sequence of messages or
communications between objects at run-time during a communications between objects at run-time during a collaboration instancecollaboration instance
Sequence diagramsSequence diagrams Show the sequence of messages passed between objects using Show the sequence of messages passed between objects using
a vertical timelinea vertical timeline
Timing diagramsTiming diagrams Fuse Sequence and State diagrams to provide a view of an Fuse Sequence and State diagrams to provide a view of an
object's state over time and messages which modify that state object's state over time and messages which modify that state
Interaction overview diagramsInteraction overview diagrams Fuse Activity and Sequence diagrams to provide allow Fuse Activity and Sequence diagrams to provide allow
interaction fragments to be easily combined with decision points interaction fragments to be easily combined with decision points and flows and flows
11112008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Use case diagramUse case diagram
A use caseA use case A description of a set of sequences of actionsA description of a set of sequences of actions Rendered as an ellipseRendered as an ellipse
NamesNames A simple nameA simple name
A path nameA path namePrefixed by the name of the packagePrefixed by the name of the package
Place orderValidate user
Sensors::Calibrate location
12122008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Use case diagramUse case diagram
An actorAn actor A coherent set of roles that users of use cases play A coherent set of roles that users of use cases play
when interacting with these use caseswhen interacting with these use cases Represents a roleRepresents a role
A humanA human
A hardware deviceA hardware device
Another systemAnother system
customer
13132008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Use case diagramUse case diagram
ContentsContents Use casesUse cases ActorsActors Dependency, generalization, and association Dependency, generalization, and association
relationshiprelationship
Common UsesCommon Uses To model the To model the contextcontext of a system of a system
All things on the outside that interact with the system All things on the outside that interact with the system constitute the system’s contextconstitute the system’s context
To model the To model the requirementsrequirements of a system of a system
14142008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Credit Card Validation System
Model the context of a systemModel the context of a system
Processcustomer bill
Performcard transaction
Reconciletransactions
Retail institution
Managecustomer account
Sponsoringfinancial institution
Customer
IndividualCustomer
CorporateCustomer
15152008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Credit Card Validation System
Model the requirements of a systemModel the requirements of a system
Processcustomer bill
Performcard transaction
Reconciletransactions
Retail institution
Managecustomer accountSponsoring
financial institution
Customer
Report onaccount status
Detectcard fraud
Managenetwork outage
16162008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
RelationshipsRelationships
A relationshipA relationship A connection among thingsA connection among things
The three most important relationshipsThe three most important relationships DependenciesDependencies GeneralizationsGeneralizations AssociationsAssociations
17172008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
DependencyDependency
A change in specification of one thing may affect A change in specification of one thing may affect another thing that uses it, but not necessarily the another thing that uses it, but not necessarily the reversereverse
Be rendered as a dashed directed lineBe rendered as a dashed directed line Directed to the thing being depended onDirected to the thing being depended on
18182008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
DependencyDependency
To decompose use cases into reusable To decompose use cases into reusable partspartsTwo stereotypesTwo stereotypes ExtendExtend
Specify that the target use case extends the Specify that the target use case extends the behavior of the sourcebehavior of the source
IncludeIncludeSpecify that the source use case explicitly Specify that the source use case explicitly incorporates the behavior of another use case at a incorporates the behavior of another use case at a location specified by the sourcelocation specified by the source
19192008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
GeneralizationGeneralization
A relationship betweenA relationship between A general thing (called the superclass or parent)A general thing (called the superclass or parent) A more specific kind of that thing (called the subclass A more specific kind of that thing (called the subclass
or child)or child)
Also called an “Also called an “is-a-kind-ofis-a-kind-of” relationship” relationshipRendered as a solid directed line with a large Rendered as a solid directed line with a large open arrowhead, pointing to the parent.open arrowhead, pointing to the parent.
20202008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
Generalization, Include, and ExtendGeneralization, Include, and Extend
Validateuser
Check password
Retinal scan
Placerush order
Place order
Trackorder
<<extend>>
<<include>>
<<include>>
21212008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
AssociationAssociation
A structural relationshipA structural relationship Specify that objects of one thing are connected to Specify that objects of one thing are connected to
objects of anotherobjects of another
Rendered as a solid line connecting the same or Rendered as a solid line connecting the same or different classesdifferent classes
Four adornmentsFour adornments NameName RoleRole MultiplicityMultiplicity AggregationAggregation
22222008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
AssociationAssociation
NameName Use the name to describe the nature of the Use the name to describe the nature of the
relationshiprelationship Can provide a direction triangle that points in the Can provide a direction triangle that points in the
direction you intend to read the namedirection you intend to read the name
Person CompanyWorks for
23232008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
AssociationAssociation
RoleRole A specific role that it plays in that relationshipA specific role that it plays in that relationship
Person Companyemployee employer
24242008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
AssociationAssociation
MultiplicityMultiplicity How many objects may be connected across an How many objects may be connected across an
instance of an associationinstance of an association Exactly one (1)Exactly one (1) Zero or one (0..1)Zero or one (0..1) Many (0 ..*)Many (0 ..*) One or more (1..*)One or more (1..*)
Person Companyemployee employer
1..* *
25252008/03/252008/03/25 Unified Modeling LanauageUnified Modeling Lanauage
AssociationAssociation
AggregationAggregation A “whole/part” relationshipA “whole/part” relationship
The whole : a larger thingThe whole : a larger thing
The parts : smaller thingsThe parts : smaller things A special kind of associationA special kind of association
With an open diamond at the whole endWith an open diamond at the whole end
Company Department
1 *