UML
Sectionsof thispresentation wereadapted from Martin Fowler UML Distilled: A
Brief Guideto theStandard Object Modeling Language, 3rd Edition
History
Design notation of variouskindsused since
programming began:
• Flow charts, Pseudo code, StructureDiagrams…
With advent of OO, many conflicting notations
(1980s, 1990s)
Thesenotationswerecombined and unified (late
1990’s)
UML extensively taught in universities
(2000 - now).
UML: Unified Modeling Language
An industry-standard graphical languagefor specifying,
visualizing, constructing, and documenting theartifactsof
softwaresystems, aswell asfor businessmodeling.
TheUML usesmostly graphical notationsto expressthe
OO analysisand design of softwareprojects. 
Simplifiesthecomplex processof softwaredesign
UML can beused to describe:
 theorganization of aprogram
 how aprogram executes
 how aprogram isused
 how aprogram isdeployed over anetwork
 …and more
What is UML?
Why UMLforModeling?
A diagram/picture= thousandswords
Usesgraphical notation to communicatemoreclearly than
natural language(imprecise) and code(too detailed).
Makesit easier for programmersand softwarearchitectsto
communicate.
Helpsacquirean overall view of asystem.
UML isno t dependent on any onelanguageor technology.
UML movesusfrom fragmentation to standardization.
3 Waysto UseUML
(Both forward & reverseengineering)
1) Sketch e.g. at white board
1) Most common, quick and informal
2) Communication & understanding
2) Blueprint
1) Detailed design, implemented by programmer
2) May havetoolssupporting diagramming
3) Programming Language
1) Toolstranslatediagramsto executablecode
During Software Lifecycle:
UMLCan Be Used at Various Stages
Analysis: OOA
• What issystem to do? What servicesisit to provide? Provide
requirementsfor designer.
Design: OOD
• What will betheparts& structureof thesystem? How will
they interact? Provideblueprint for programmer.
Programming: OOP
Classification of UMLDiagrams
Structure
1) Class diagram
2) Component diagram (cmptscan beindependently
purchased and replaced)
3) Component structurediagram
4) Deployment diagram (what goeson what machine&
place)
5) Object diagram
6) Packagediagram (pkg = group of classes, e.g.
namespace)
There are 13 + Kinds of UMLDiagrams
Classification of UMLDiagrams
(cont.)
Behavior
7) Activity diagram (flow chart)
8) Use Case diagram (scenarios foruse of system)
9) StateMachinediagram
10) Sequence diagram
11) Communication diagram (dataflow diagrams)
12) Interaction diagram (activity + sequencediagrams)
13) Timing diagram
Class Diagrams
Class diagrams
A classdiagram isoften all that isneeded to describea
particular Design Pattern
A classdiagram showsclasses, interfaces, and their
relationships
We’ll cover most of classesand interfaces, and afew of the
most important relationships
Thepurposeof theclassdiagram isto show thetypesbeing
modeled within thesystem.
10
"classifiers."
UML modelstypesmay include:
aclass
an interface
adatatype
acomponent.
Class
Class Name
Attribute : type
Operation (arg list) : return type
Abstract operation
Various parts are optional
Example UMLClass Diagram
13
http://www.ibm.com/ -http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/bell_fig5.jpg
Instance Specification
(Object)
ObjectName: Class Name
Attribute : type
Operation (arg list) : return
type
Abstract operation
Various parts are optional
An example of Class
Account_Name
- Custom_Name
- Balance
+AddFunds( )
+WithDraw( )
+PayInvoice( )
Name
Attributes
Operations
Class Example
class Checking {
private:
char Customer_name[20];
float Balance;
public:
AddFunds(float);
WithDraw(float);
PayInvoice(float);
set_name(string);
get_name();
set_balance(float);
get_balance();
};
Relationships between Class
Diagrams
Association-- arelationship between instancesof thetwo classes. There
isan association between two classesif an instanceof oneclassmust know
about theother in order to perform itswork. In adiagram, an association is
alink connecting two classes.
Aggregation-- an association in which oneclassbelongsto acollection.
An aggregation hasadiamond end pointing to thepart containing the
whole.
Generalization-- an inheritancelink indicating oneclassisasuperclass
of theother. A generalization hasatrianglepointing to thesuperclass.
17
Notation of Class Diagram: association
Bi-directional association
Associationsareassumed to bebi-directional
e.g. Flight and plane
notation:
Uni-directional association
e.g. Order and item
notation:
Associations represent relationships between instances
of classes .
Association: Multiplicity and Roles
University Person
1
1
*
*
Multiplicity
Symbol Meaning
1 One and only one
0..1 Zero or one
M..N From M to N (natural language)
* From zero to any positive integer
0..* From zero to any positive integer
1..* From one to any positive integer
0…8.. From zero to eight
8..14 From eight to fourteen
teacheremployer
RoleRole
“A given university groups many
people; some act as students, others
as teachers. A given student
belongs to a single university; A
given staff belongs to a single
university; a given teacher may or
may not be working for the university
at a particular time.”
student
staff
*
0..1
Notation of Class Diagram: Aggregation
AGGREGATION
Aggregation: expresses a relationship among
instances
of related classes.
Containee Classes
Flat
Rooms Storage Room
Example 1
Containee Classes
Car
Motor Wheels
Example2
AGGREGATION
41
Generalization
(Inheritance)
Supertype
Subtype 1 Subtype 2
Generalization expresses a relationship among related classes. It is a
class that includes its subclasses.
Generalization Example
http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/bell_fig10.gif
Elements of Sequence Diagrams
Name: Class
New object
Create
Message
Return
Delete
Self-call
Lifelines
The dotted line that extends down the
vertical axis from the base of each object.
Messages
Labeled as arrows, with the arrowhead
indicating the direction of the call.
Activation bar
The long, thin boxes on the lifelines are
method-invocation boxes indicting that
indicate processing is being performed by
the target object/class to fulfill a message.
Rectangle also denotes when object is
deactivated.
Deletion (X)
Object’s life ends at that point
Activation bar
Sequence Diagrams
Example forSequence Diagram
[Fowler]
Wehavean order and aregoing to invokeacommand on it to
calculateitsprice. To do that, theorder needsto look at all theline
itemson theorder and determinetheir prices, which arebased on
thepricing rulesof theorder line’sproducts. Having donethat for
all thelineitems, theorder then needsto computean overall
discount, which isbased on rulestied to thecustomer.
Example forSequence Diagram
[Fowler]
Wehavean order and aregoing to invokeacommand on it
to calculateitsprice. To do that, theorder needsto look at
all thelineitemson theorder and determinetheir prices,
which arebased on thepricing rulesof theorder line’s
products. Having donethat for all thelineitems, theorder
then needsto computean overall discount, which isbased
on rulestied to thecustomer.
Example Sequence Diagram
anOrder anOrderLine aProduct aCustomer
calculatePrice
getQuantity
getProduct
getPricingDetails
getBasePrice
calculateDiscounts
getDiscountInfo
aProductFound
message
Participant Lifeline
Return
Activation
Self call
Message
Operations
Object: Class
Message
USECASES DIAGRAM
Use cases. A usecasedescribesasequenceof actionsthat provide
something of measurablevalueto an actor and isdrawn asa
horizontal ellipse.
Actors. An actor isaperson, organization, or external system that
playsarolein oneor moreinteractionswith your system. Actorsare
drawn asstick figures
Website Administration
Who managesthewebsite?
What typeof different rolesof admin and help desk have
Website Administration
g
www.uml-diagrams.or
Business Use Case Diagram forAirport Check-
In and Security Screening
Business actors :?
Business use cases ?
PLEASE DISCUSS AND EXPLAIN WHY?
Business Use Case Diagram forAirport Check-
In and Security Screening
Business actors :Passenger,
Tour Guide,
Minor (Child),
Passenger with Special Needs
(all playing external rolesin relation to airport
business.)
Business use cases are
 Individual Check-In,
 Group Check-In (for groupsof
tourists),
 Security Screening
Baggage Check-in and
Baggage Handling extend Check-In usecases, WHY?
Business Use Case Diagram forAirport Check-
In and Security Screening
Activity Diagram
Activity diagram isused to show message
flow from oneactivity to another.
Activity Diagrams:
Draw theactivity flow of asystem.
Describethesequencefrom oneactivity
to another.
Describetheparallel, branched and
concurrent flow of thesystem.
http://www.sparxsystems.com/resources/uml2_tutorial/uml2_activitydiagram.html
An initial or start node Activity final node
Object
Decision Node
Fork/Branch and Join
Nodes
Merger
Node

UML Basics

  • 1.
    UML Sectionsof thispresentation wereadaptedfrom Martin Fowler UML Distilled: A Brief Guideto theStandard Object Modeling Language, 3rd Edition
  • 2.
    History Design notation ofvariouskindsused since programming began: • Flow charts, Pseudo code, StructureDiagrams… With advent of OO, many conflicting notations (1980s, 1990s) Thesenotationswerecombined and unified (late 1990’s) UML extensively taught in universities (2000 - now).
  • 3.
    UML: Unified ModelingLanguage An industry-standard graphical languagefor specifying, visualizing, constructing, and documenting theartifactsof softwaresystems, aswell asfor businessmodeling. TheUML usesmostly graphical notationsto expressthe OO analysisand design of softwareprojects.  Simplifiesthecomplex processof softwaredesign UML can beused to describe:  theorganization of aprogram  how aprogram executes  how aprogram isused  how aprogram isdeployed over anetwork  …and more What is UML?
  • 4.
    Why UMLforModeling? A diagram/picture=thousandswords Usesgraphical notation to communicatemoreclearly than natural language(imprecise) and code(too detailed). Makesit easier for programmersand softwarearchitectsto communicate. Helpsacquirean overall view of asystem. UML isno t dependent on any onelanguageor technology. UML movesusfrom fragmentation to standardization.
  • 5.
    3 Waysto UseUML (Bothforward & reverseengineering) 1) Sketch e.g. at white board 1) Most common, quick and informal 2) Communication & understanding 2) Blueprint 1) Detailed design, implemented by programmer 2) May havetoolssupporting diagramming 3) Programming Language 1) Toolstranslatediagramsto executablecode
  • 6.
    During Software Lifecycle: UMLCanBe Used at Various Stages Analysis: OOA • What issystem to do? What servicesisit to provide? Provide requirementsfor designer. Design: OOD • What will betheparts& structureof thesystem? How will they interact? Provideblueprint for programmer. Programming: OOP
  • 7.
    Classification of UMLDiagrams Structure 1)Class diagram 2) Component diagram (cmptscan beindependently purchased and replaced) 3) Component structurediagram 4) Deployment diagram (what goeson what machine& place) 5) Object diagram 6) Packagediagram (pkg = group of classes, e.g. namespace) There are 13 + Kinds of UMLDiagrams
  • 8.
    Classification of UMLDiagrams (cont.) Behavior 7)Activity diagram (flow chart) 8) Use Case diagram (scenarios foruse of system) 9) StateMachinediagram 10) Sequence diagram 11) Communication diagram (dataflow diagrams) 12) Interaction diagram (activity + sequencediagrams) 13) Timing diagram
  • 9.
  • 10.
    Class diagrams A classdiagramisoften all that isneeded to describea particular Design Pattern A classdiagram showsclasses, interfaces, and their relationships We’ll cover most of classesand interfaces, and afew of the most important relationships Thepurposeof theclassdiagram isto show thetypesbeing modeled within thesystem. 10
  • 11.
  • 12.
    Class Class Name Attribute :type Operation (arg list) : return type Abstract operation Various parts are optional
  • 13.
    Example UMLClass Diagram 13 http://www.ibm.com/-http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/bell_fig5.jpg
  • 14.
    Instance Specification (Object) ObjectName: ClassName Attribute : type Operation (arg list) : return type Abstract operation Various parts are optional
  • 15.
    An example ofClass Account_Name - Custom_Name - Balance +AddFunds( ) +WithDraw( ) +PayInvoice( ) Name Attributes Operations
  • 16.
    Class Example class Checking{ private: char Customer_name[20]; float Balance; public: AddFunds(float); WithDraw(float); PayInvoice(float); set_name(string); get_name(); set_balance(float); get_balance(); };
  • 17.
    Relationships between Class Diagrams Association--arelationship between instancesof thetwo classes. There isan association between two classesif an instanceof oneclassmust know about theother in order to perform itswork. In adiagram, an association is alink connecting two classes. Aggregation-- an association in which oneclassbelongsto acollection. An aggregation hasadiamond end pointing to thepart containing the whole. Generalization-- an inheritancelink indicating oneclassisasuperclass of theother. A generalization hasatrianglepointing to thesuperclass. 17
  • 18.
    Notation of ClassDiagram: association Bi-directional association Associationsareassumed to bebi-directional e.g. Flight and plane notation: Uni-directional association e.g. Order and item notation: Associations represent relationships between instances of classes .
  • 19.
    Association: Multiplicity andRoles University Person 1 1 * * Multiplicity Symbol Meaning 1 One and only one 0..1 Zero or one M..N From M to N (natural language) * From zero to any positive integer 0..* From zero to any positive integer 1..* From one to any positive integer 0…8.. From zero to eight 8..14 From eight to fourteen teacheremployer RoleRole “A given university groups many people; some act as students, others as teachers. A given student belongs to a single university; A given staff belongs to a single university; a given teacher may or may not be working for the university at a particular time.” student staff * 0..1
  • 20.
    Notation of ClassDiagram: Aggregation AGGREGATION Aggregation: expresses a relationship among instances of related classes. Containee Classes Flat Rooms Storage Room Example 1 Containee Classes Car Motor Wheels Example2 AGGREGATION 41
  • 21.
    Generalization (Inheritance) Supertype Subtype 1 Subtype2 Generalization expresses a relationship among related classes. It is a class that includes its subclasses.
  • 22.
  • 23.
    Elements of SequenceDiagrams Name: Class New object Create Message Return Delete Self-call Lifelines The dotted line that extends down the vertical axis from the base of each object. Messages Labeled as arrows, with the arrowhead indicating the direction of the call. Activation bar The long, thin boxes on the lifelines are method-invocation boxes indicting that indicate processing is being performed by the target object/class to fulfill a message. Rectangle also denotes when object is deactivated. Deletion (X) Object’s life ends at that point Activation bar Sequence Diagrams
  • 24.
    Example forSequence Diagram [Fowler] Wehaveanorder and aregoing to invokeacommand on it to calculateitsprice. To do that, theorder needsto look at all theline itemson theorder and determinetheir prices, which arebased on thepricing rulesof theorder line’sproducts. Having donethat for all thelineitems, theorder then needsto computean overall discount, which isbased on rulestied to thecustomer.
  • 25.
    Example forSequence Diagram [Fowler] Wehaveanorder and aregoing to invokeacommand on it to calculateitsprice. To do that, theorder needsto look at all thelineitemson theorder and determinetheir prices, which arebased on thepricing rulesof theorder line’s products. Having donethat for all thelineitems, theorder then needsto computean overall discount, which isbased on rulestied to thecustomer.
  • 26.
    Example Sequence Diagram anOrderanOrderLine aProduct aCustomer calculatePrice getQuantity getProduct getPricingDetails getBasePrice calculateDiscounts getDiscountInfo aProductFound message Participant Lifeline Return Activation Self call Message Operations Object: Class Message
  • 27.
    USECASES DIAGRAM Use cases.A usecasedescribesasequenceof actionsthat provide something of measurablevalueto an actor and isdrawn asa horizontal ellipse. Actors. An actor isaperson, organization, or external system that playsarolein oneor moreinteractionswith your system. Actorsare drawn asstick figures
  • 28.
    Website Administration Who managesthewebsite? Whattypeof different rolesof admin and help desk have
  • 29.
  • 30.
    Business Use CaseDiagram forAirport Check- In and Security Screening Business actors :? Business use cases ? PLEASE DISCUSS AND EXPLAIN WHY?
  • 31.
    Business Use CaseDiagram forAirport Check- In and Security Screening Business actors :Passenger, Tour Guide, Minor (Child), Passenger with Special Needs (all playing external rolesin relation to airport business.) Business use cases are  Individual Check-In,  Group Check-In (for groupsof tourists),  Security Screening Baggage Check-in and Baggage Handling extend Check-In usecases, WHY?
  • 32.
    Business Use CaseDiagram forAirport Check- In and Security Screening
  • 33.
    Activity Diagram Activity diagramisused to show message flow from oneactivity to another. Activity Diagrams: Draw theactivity flow of asystem. Describethesequencefrom oneactivity to another. Describetheparallel, branched and concurrent flow of thesystem.
  • 34.
    http://www.sparxsystems.com/resources/uml2_tutorial/uml2_activitydiagram.html An initial orstart node Activity final node Object Decision Node Fork/Branch and Join Nodes Merger Node