Introduction To UML: Shiyuan Jin
Introduction To UML: Shiyuan Jin
Introduction To UML: Shiyuan Jin
Shiyuan Jin
Fall, 2006
Overview
What is UML? A brief history of UML and its origins. Understanding the basics of UML. UML diagrams UML Modeling tools
What is UML?
UML: Unified Modeling Language An industry-standard graphical language for specifying, visualizing, constructing, and documenting the artifacts of software systems, as well as for business modeling. The UML uses mostly graphical notations to express the OO analysis and design of software projects. Simplifies the complex process of software design
History
Time
Year Version
2003: 2001: 1999: 1997: 1996: 1995: UML 2.0 UML 1.4 UML 1.3 UML 1.0, 1.1 UML 0.9 & 0.91 Unified Method 0.8
OMT - 2
OMT - 1
what the system is supposed to do Displays the relationship among actors and use cases. Different from traditional flow chart.
Class Diagram: static relationships between classes. Describe the types of objects in the system and various kinds of static relationship that exist among them. Sequence Diagram: Displays the time sequence of the objects participating in the interaction.
State Diagram
Displays the sequences of states that an object of an interaction goes through during its life in response to received stimuli, together with its responses and actions.
Component Diagram
Illustrate the organizations and dependencies of the physical components in a system. A higher level than class diagrams.
Use Case
Borrow
Employee
Client
Order Title
Fine Remittance
Supervisor
A generalized description of how a system will be used. Provides an overview of the intended functionality of the system
Use Case Diagram(core relationship) Association: communication between an actor and a use case; represented by a solid line.
Generalization: relationship between one general use case and one specific use case. Represented by a line with a triangular arrow head toward the parent use case, the more general modeling element.
waitress
employee
or in MS Visio A Use Case may be included by one or more Use Cases, so it reduces duplication of functionality. Example: the <list orders> Use Case may be included every time when the <modify order> Use Case is run.
with an arrow toward the base case. The extending use case may add behavior to the base use case. The base class declares extension points. <<extend>>
Used when exceptional circumstances are encountered. For example, the <get approval> Use Case may optionally extend the regular <modify order> Use Case. Note: other expressions. For example, in MS Visio
<<uses>>
<<extends>>
(TogetherSoft, Inc)
Class Diagram
Each class is represented by a rectangle subdivided into three compartments Name Attributes Operations Modifiers are used to indicate visibility of attributes and operations. + is used to denote Public visibility (everyone) # is used to denote Protected visibility (friends and derived) - is used to denote Private visibility (no one) By default, attributes are hidden and operations are visible. The last two compartments may be omitted to simplify the class diagrams
An example of Class
Name Attributes
Operations
Supertype
Example:
Customer
Regular Customer
Loyalty Customer
Subtype1
Subtype2
or:
Customer
Generalization expresses a relationship among related classes. It is a class that includes its subclasses.
Regular Customer
Loyalty Customer
Part Classes
Example
Engine
Transmission
Class E1
Class E2
Containee Classes
Example
Bag
Apples
Milk
Multiplicity: mandatory
class
1
Customer
-name -address
+creditRating() : String()
*
Association
Operations
Generalization
Corporate Customer
Personal Customer
-creditCard#
Multiplicity: optional
*
0..1 Employee
*
OrderLine
-quantity: Integer -price: Money -isSatisfied: Boolean
Product
Third Edition]
Self-Call: A message that an Object sends to itself. Condition: indicates when a message is sent. The message is sent only if the condition is true. Condition
Iteration
Self-Call
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. Activation bar Rectangle also denotes when object is deactivated. Deletion Placing an X on lifeline Objects life ends at that point
Lifeline
Create
Return
X
Deletion
Sequence Diagram
User
Message
1: look up () 2: title data ()
Catalog
Reservations
6 : remove reservation ()
Sequence diagrams demonstrate the behavior of objects in a use case by describing the objects and the messages they pass. The horizontal dimension shows the objects participating in the interaction. The vertical arrangement of messages indicates their order. The labels may contain the seq. # to indicate concurrency.
The numbers next to the messages are called sequence numbers. They show the sequence of the messages as they are passed between the objects.
Convey the same information as sequence diagrams, but focus on object roles instead of the time sequence.
6: remove reservation 3 : [not available] reserve title User 6 : borrow title 2: title data 1: look up 5: title available Reservations
CRC Card
A collection of standard index cards, each of which is divided into three sections; can be printed or hand-written. Benefits: It is easy to describe how classes work by moving cards around; allows to quickly consider alternatives.
Class
Reservations
Collaborators
Catalog User session
Find responsibilities
Know what a class does; what information you wish to maintain about it.
Define collaborators
A class often needs to collaborate with other classes to get the job done. Collaboration diagram is an example to show class relationship.
State Diagrams
(Billing Example)
State Diagrams show the sequences of states an object goes through during its life cycle in response to stimuli, together with its responses and actions; an abstraction of all possible behaviors.
Start
Unpaid
Invoice created paying
End
Paid
Invoice destroying
Show the initial state by drawing an arrow from a black filled circle to the initial state.
Show the end state by drawing an arrow to a circle with a filled circle inside it.
State Diagrams
(Traffic light example) Traffic Light
Start
Component Diagram
Illustrate the organizations and dependencies of the physical components in a system. Has a higher level of abstraction than a Class diagram - usually implemented by one or more classes. Symbols and Notations
Components a large rectangle with two smaller rectangles on the side.
Dependencies
dashed arrows.
customer
account
Order provides a component interface, which is a collection of one or more methods with or without attributes. Account and customer components are dependent upon the interface of the order.
Microsoft Visio
(Radu Marinescu[5])
A cleaner design
(Radu Marinescu[5])
Reference
1. UML Distilled: A Brief Guide to the Standard Object Modeling Language
Martin Fowler, Kendall Scott
5. http://labs.cs.utt.ro/labs/acs/html/lectures/4/lecture4.pdf