an introduction to uml - idatddc32/lectures/tddc32-6.1-uml.pdf · an introduction to uml calin...
Post on 12-Jun-2019
219 Views
Preview:
TRANSCRIPT
An introduction to UMLCalin Curescu
An introduction to UML
Calin Curescu
Figures taken from Borland tutorial
http://bdn.borland.com/article/0,1410,31863,00.html
27 pagesTDDC32 lecture 6, 2006
An introduction to UMLCalin Curescu
2 of 27TDDC32 lecture 6, 2006
What is a Process?
• A Process is a series of definable, repeatable, and measurable tasks leading to a useful result.
• Analysis: User needs are gathered and converted into software requirements. – What is to be done to meet user needs?
• Design: Determines organisation of various modules in the software system – How to meet the user needs?
• Construction: Coding is the main activity in this phase • Testing:
– Unit testing, integration testing, and system testing. • Implementation• Maintenance (some say 80% of costs)
An introduction to UMLCalin Curescu
3 of 27TDDC32 lecture 6, 2006
Unified process (RUP)
• Good practices of modern software development
• Uses UML :)
• Iterative• Incremental• Architecture-Centric• Use Case driven
An introduction to UMLCalin Curescu
4 of 27TDDC32 lecture 6, 2006
What is UML
• Software development– A Process– A modeling language
• The Unified Modeling Language (UML) is called a modeling language, not a method. The modeling language is the notation that methods use to express designs.
• Models in software help us to visualize, specify, construct and document the artifacts of a software intensive system.
• UML provide various perspectives– User, Structural, Behavioral, Implementation, Environment– Using diagrams – why?
1 bitmap = 1 megaword
An introduction to UMLCalin Curescu
5 of 27TDDC32 lecture 6, 2006
Diagrams
• Use case diagrams • Class diagrams • Object diagrams • Sequence diagrams • Collaboration diagrams• Statechart diagrams • Activity diagrams • Component diagrams • Deployment diagrams
An introduction to UMLCalin Curescu
6 of 27TDDC32 lecture 6, 2006
Use case diagrams
• What a system does from the standpoint of an external observer
• Emphasis is on what a system does rather than how
• A scenario is an example of what happens when someone interacts with the system
• Use case is a summary of scenarios for a single task or goal
• Actors are simply roles that people or objects play– Initiates the events
An introduction to UMLCalin Curescu
7 of 27TDDC32 lecture 6, 2006
A use case example
• Use case “Make appointment”– Represented by ovals
• Actor: “Patient”– Represented by stick figures
• Connection: “communication association”– Lines that link actors to use cases
A patient calls the clinic to make an appointment for a yearly checkup. The receptionist finds the nearest empty time slot in the appointment book and schedules the appointment for that time slot.
An introduction to UMLCalin Curescu
8 of 27TDDC32 lecture 6, 2006
Use case diagrams
• Collection of actors, use cases, and their communications• Can also show:
– System boundaries• Separates actors from system
– Generalizations• One use case is a special case of another
– Includes• Several subtask can be identified out of a larger use case
– Extensions• One use case is a variation of another• Do not confuse with generalization (like expands)• Extension point
An introduction to UMLCalin Curescu
9 of 27TDDC32 lecture 6, 2006
Use case diagram example
An introduction to UMLCalin Curescu
10 of 27TDDC32 lecture 6, 2006
Class diagram
• Static overview of a system• UML class notation
– Class name• Italics: abstract classes
– Attributes– Operations
• Relationships– Association
• Knows about the other end– Aggregation
• One class belongs to a collection• Diamond on the container side
– Generalization• One class is other’s superclass• Triangle points to superclass
• Relationships• Connected links• An end may have a role
name• Navigability
• Arrow - direction of association or query (“has”)
• No arrow – bidirectional• Multiplicity
• number of possible instances of the class associated with a single instance of the other end
An introduction to UMLCalin Curescu
11 of 27TDDC32 lecture 6, 2006
Class diagram exampleMultiplicities Meaning
0..1 zero or one instance. The notation n . . m indicates n to m instances.
0..* or * no limit on the number of instances (including none)
1 exactly one instance
1..* at least one instance
An introduction to UMLCalin Curescu
12 of 27TDDC32 lecture 6, 2006
Composition
• Stronger than aggregation• The part can belong to only one whole
– Cannot exist without whole• Filled diamond at the whole end
An introduction to UMLCalin Curescu
13 of 27TDDC32 lecture 6, 2006
Visibility and scope
An introduction to UMLCalin Curescu
14 of 27TDDC32 lecture 6, 2006
Dependencies and constraints
• Dependency– A change in a class may force a change in the other– Drawn as dotted lines– Observe the arrowQ: Are dependencies good?
• Constraint– A condition that every implementation of the system must
satisfy– Constraints are written in curly braces { }
An introduction to UMLCalin Curescu
15 of 27TDDC32 lecture 6, 2006
Example dep. & const.
An introduction to UMLCalin Curescu
16 of 27TDDC32 lecture 6, 2006
Interfaces
• Implementation (or realization) relationship with a class
• Dashed line, triangle points to interface
• Set of operation signatures
• Interfaces and their method names are written in italics
An introduction to UMLCalin Curescu
17 of 27TDDC32 lecture 6, 2006
Object diagrams
• Show more complicated relationships
• Instance names are underlined
• Class names are preceded by : (colon)
An introduction to UMLCalin Curescu
18 of 27TDDC32 lecture 6, 2006
Sequence diagram
• Sort of interaction diagram, dynamic• Details how operations are carried out
– What messages and when• Timeline towards bottom of page• Life line
– Shows object exists– Dotted line– Can contain activation bars
• Triggered by received messages• Messages
– Directed horizontal lines• Can be a self call• Iterations denoted by *• Conditions denoted with [ ]
– Usually implemented by method invocation but not always
An introduction to UMLCalin Curescu
19 of 27TDDC32 lecture 6, 2006
Sequence diagram example
An introduction to UMLCalin Curescu
20 of 27TDDC32 lecture 6, 2006
Asynchronous messages
Symbol Meaning
simple message which may be synchronous or asynchronous
simple message return (optional)
a synchronous message
an asynchronous message
An introduction to UMLCalin Curescu
21 of 27TDDC32 lecture 6, 2006
Collaboration diagrams• Also an interaction diagram• Focus on object roles instead of
message sending times• Links represent messages• Sequence number
– Can be used to show order in a message sequence
– Top level message numbered 1– Messages at same level have same
prefix but suffixes grow according to the order when they occur
An introduction to UMLCalin Curescu
22 of 27TDDC32 lecture 6, 2006
Statechart diagrams
• Possible states of the system– Rounded rectangles– Observe special initial and final states
• Transitions– From a state to another, represented by arrows– Triggering conditions or events written besides arrows– Guards are denoted in [ ]
• Actions– Can be attached to transitions or states
• A validating state does not need external event as trigger– Denoted by a preceding /
An introduction to UMLCalin Curescu
23 of 27TDDC32 lecture 6, 2006
Statechart diagrams Example
An introduction to UMLCalin Curescu
24 of 27TDDC32 lecture 6, 2006
Activity diagram
• Fancy flowchart, related to statechart– Focuses on flows (not on the states)– Has a sense of sequentiality (order in time)
• Swimlanes determine which object is responsible for what• A single transition comes out from each activity
– May branch or merge – represented by a hollow diamond– Guard expressions on any transitions coming from a branch
• Denoted in [ ]• Synchronization bars
– Denote beginning (fork) and end (join) of parallel activities– Denoted by solid bars
An introduction to UMLCalin Curescu
25 of 27TDDC32 lecture 6, 2006
Activity diagram example
An introduction to UMLCalin Curescu
26 of 27TDDC32 lecture 6, 2006
Component and deployment diagrams
• A deployment diagram shows the physical configuration of hardware and software
• A component is a code module– Denoted as a rectangle with two bars on upper left
• A node represents physical hardware– Each component belongs to a node
An introduction to UMLCalin Curescu
27 of 27TDDC32 lecture 6, 2006
Deployment diagram example
An introduction to UMLCalin Curescu
28 of 27TDDC32 lecture 6, 2006
Reading
• Mandatory– http://pigseye.kennesaw.edu/~dbraun/csis4650/A&D/UML_tut
orial/index.htm– http://bdn.borland.com/article/0,1410,31863,00.html
• Others
top related