Вы находитесь на странице: 1из 93

Unified Modeling Language

Prof.K.Phani Kumar ICFAI School of IT, Hyderabad phanikumar@isitindia.org

Agenda
What is Model? Why do we Model? Importance of Modeling? Four principles of Modeling? UML History of the UML UML Diagrams Activity Diagram Use Case Diagram Sequence Diagram Collaboration Diagram Class Diagram State Diagram Component Diagram Deployment Diagram
2

What Is a Model?
A model is a simplification of reality.

Why Do We Model?
Modeling achieves four aims:
Helps us to visualize a system as we want it to be. Permits us to specify the structure or behavior of a system. Gives us a template that guides us in constructing a system. Documents the decisions we have made.

We build models of complex systems because we cannot comprehend such a system in its entirety. We build models to better understand the system we are developing.

The Importance of Modeling


Less Important More Important

Paper Airplane

Fighter Jet

The Importance of Modeling

Who Should Model?

Business Analyst

Requirements and Business Models

HTML CGI XML JavaScript

Web Content Developer

Software Engineer

C++ Java SW Models

Data Models

Database Designer

Software Teams Often Do Not Model


Many software teams build applications approaching the problem like they were building paper airplanes
Start coding from project requirements Work longer hours and create more code Lacks any planned architecture Doomed to failure

Modeling is a common thread to successful projects.

Four Principles of Modeling


The model you create influences how the problem is attacked. Every model may be expressed at different levels of precision. The best models are connected to reality. No single model is sufficient.

Principle 1: The Choice of Model Is Important


The models you create profoundly influence how a problem is attacked and how a solution is shaped.
In software, the models you choose greatly affect your world view. Each world view leads to a different kind of system.
Design Model

Deployment Diagram Process Model


10

Principle 2: Levels of Precision May Differ


Every model may be expressed at different levels of precision.
The best kinds of models let you choose your degree of detail, depending on: who is viewing the model. why they need to view it.

View for Designers

View for Customers

11

Principle 3: The Best Models Are Connected to Reality All models simplify reality. A good model reflects potentially fatal characteristics.

12

Principle 4: No Single Model Is Sufficient


No single model is sufficient. Every non-trivial system is best approached through a small set of nearly independent models.
Create models that can be built and studied separately, but are still interrelated.
Logical View
Analysts/Designers Structure

Implementation View

End-user Functionality

Programmers Software management

Use-Case View Process View


System integrators Performance scalability throughput

Deployment View
System engineering System topology delivery, installation communication

13

What is the UML?


The UML is the standard language for visualizing, specifying, constructing, and documenting the artifacts of a softwareintensive system
14

Inputs to the UML


Booch Rumbaugh Jacobson
Meyer
Before and after conditions

Fusion

Operation descriptions, message numbering

Harel
State charts

Embley
Singleton classes, high -level view

Gamma, et.al
Frameworks, patterns, notes Shlaer - Mellor Object lifecycles

Wirfs-Brock

Odell
Classification

Responsibilities

15

History of the UML


Planned major revision (2002)

UML 2.0

Approved minor revision 2001


Public Feedback

UML 1.4
UML 1.3 UML 1.1 UML 1.0 UML 0.9 Unified Method 0.8

Current minor revision 1999


OMG Acceptance, Nov 1997 Final submission to OMG, Sept 1997 First submission to OMG, Jan 1997

UML partners
Web - June 1996 OOPSLA 95

Other methods

OOSE
16

Booch method

OMT

What Is the UML?


The UML is a language for
Visualizing Specifying Constructing Documenting

the artifacts of a software-intensive system.

17

The UML Is a Language for Visualizing


Communicating conceptual models to others is prone to error unless everyone involved speaks the same language. There are things about a software system you cant understand unless you build models. An explicit model facilitates communication.
18

The UML Is a Language for Specifying


The UML builds models that are precise, unambiguous, and complete.

19

The UML Is a Language for Constructing


UML models can be directly connected to a variety of programming languages.
Maps to Java, C++, Visual Basic, and so on Tables in a RDBMS or persistent store in an OODBMS Permits forward engineering Permits reverse engineering

20

The UML Is a Language for Documenting


The UML addresses documentation of system architecture, requirements, tests, project planning, and release management.
Use Case Diagram Activity Diagram
Actor A Actor B

State Transition Diagram


add file add file [ numberOffile==MAX ] / flag OFF Writing Openning close file

Domain Expert

Use Case 1

[yes] Actor B

Actor A

Use Case 2

close file Closing Reading

Deployment Diagram
- 95 : - NT: - : , - IBM : , Window95 Windows95 Windows95

Use Case 3

.EXE

9: sortByName ( )

Class Diagram
DocumentList FileMgr Document add( ) delete( ) name : int docid : int numField : int get( ) open( ) close( ) read( ) sortFileList( ) create( ) fillDocument( ) Windows NT fetchDoc( ) sortByName( ) read() fill the code.. 4: create ( ) 8: fillFile ( )

Windows NT

Solaris

.EXE Alpha UNIX .EXE

mainWnd : MainWnd
1: Doc view request ( ) L

IBM Mainframe

2: fetchDoc( )

gFile : GrpFile

FileList fList add( ) delete( )

Repository FileManager

User Interface Definition

user : fileMgr : FileMgr


3: create ( ) rep 6: fillDocument ( ) Repository (from Persistence) 7: readFile ( ) 5: readDoc ( ) name : char * = 0 readDoc( ) readFile( ) read( ) open( ) create( ) fillFile( ) File

Document
GrpFile

read( )

document : Document repository : Repository

GraphicFile

File

FileList

Collaboration Diagram Component Diagram


mainWnd user
. 1: Doc view request ( )

fileMgr : FileMgr

document : Document

gFile

repository

2: fetchDoc( ) 3: create ( )

Source Code edit, compile, debug, link

4: create ( )

5: readDoc ( )

6: fillDocument ( )

7: readFile ( )

8: fillFile ( ) . 9: sortByName ( )

Model space

Sequence Diagram

Forward Engineering (Code Generation) and Reverse Engineering


19 21

Executable System

What Type of Process Most Benefits the UML?


The UML is largely process independent. A process fully benefits from the UML when the process is:
Use-case driven Architecture-centric Iterative and incremental
Builduse-case Build Use-Cases model Object analysis Validate/ Test Validate/ test

O-O Analysis

Iteration an d R eu se
Using TOOLS CASE and/or OO programing languages User satisfaction Usability & QA Tests

Design classes, define attributes and methods

Build object & dynamic model

Build UI and prototype

O-O
Implementation

O-O Design
22

U se r sa tisfa c tio n test, u sa b ility te st q u a lity a ssu r a nc e test

A Use-Case Driven Process


Use cases defined for a system are the basis for the entire development process. Benefits of use cases:
Concise, simple, and understandable by a wide range of stakeholders. Help synchronize the content of different models.

Check Balance Customer

Withdraw Money

23

An Architecture-Centric Process
A systems architecture is used as a primary artifact for conceptualizing, constructing, managing, and evolving the system under development. Benefits:
Intellectual control over a project to manage its complexity and to maintain system integrity. Effective basis for large-scale reuse. A basis for project management. Assistance in component-based development.

24

An Iterative and Incremental Process


Critical risks are resolved before making large investments. Initial iterations enable early user feedback. Testing and integration are continuous. Objective milestones focus on the short term. Progress is measured by assessing implementations. Partial implementations can be deployed.

25

Iterative Development
Iteration 1
R

Iteration 2
R D

Iteration 3
R D

D
C I T

C
I T

C
I T

T I M E

Earliest iterations address greatest risks. Each iteration produces an executable release, an additional increment of the system. Each iteration includes integration and test.
26

UML Diagrams
Use case Activity Sequence Collaboration Class State chart Object Component Deployment

27

28

What Is System Behavior?


System behavior is how a system acts and reacts.
It is the outwardly visible and testable activity of a system.

System behavior is captured in use cases.


Use cases describe the system, its environment, and the relationship between the system and its environment.

29

What Is a Use-Case Model?


A model that describes a systems functional requirements in terms of use cases. A model of the systems intended functions (use cases) and its environment (actors).
View Report Card

Student

Register for Courses

Login

30

What Are the Benefits of a Use-Case Model?


Used to communicate with the end users and domain experts
Provides buy-in at an early stage of system development Insures a mutual understanding of the requirements

Used to identify
Who interacts with the system and what the system should do The requirements for the system interfaces

Used to verify
All requirements have been captured The development team understands the requirements
31

Major Concepts in Use-Case Modeling


An actor represents anything that interacts with the system. A use case defines a set of use-case instances, where each instance is a sequence of actions a system performs that yields an observable result of value to a particular actor.

Actor

Use Case

32

What Is an Actor?
Actors are not part of the system. Actors represent roles a user of the system can play. They can represent a human, a machine, or another system. They can actively interchange information with the system. They can be a giver of information. They can be a passive recipient of information. Actors are EXTERNAL.

Actor

33

What Is a Use Case?


Defines a set of use-case instances, where each instance is a sequence of actions a system performs that yields an observable result of value to a particular actor.
A use case models a dialogue between one or more actors and the system A use case describes the actions the system takes to deliver something of value to the actor

Use Case
34

Use Cases and Actors


A use case models a dialog between actors and the system. A use case is initiated by an actor to invoke a certain functionality in the system.

Actor
Communicate-association

Use Case

35

How Would You Read This Diagram?


View Report Card

Student Register for Courses Maintain Professor Information Course Catalog

Login
Maintain Student Information

Select Courses to Teach


Registrar Professor

Submit Grades

Close Registration

Billing System

36

Use

Case

Diagram

Example

Use Case Diagram Example for College Registration System A student may register for classes during a specified registration period. To register, a student must see their advisor. The advisor must approve each course that the student has selected. The advisor will use the registration system to determine if the student has met the course prerequisites, is in good academic standings and is eligible to register.
37

If the advisor approves the courses, the advisor enters the student's college id into the course registration system. The course registration number for each course is entered. The course description, course number and section for those courses will automatically display. The system will check for schedule conflicts before saving the registrations. A bill for the courses will print in the Bursar's office. The student should proceed to pick it up.
38

Faculty can use the registration system to check enrolments in their classes, get a class list, check a student's transcript, look up a student's phone number and other such student information. The registrar can use the registration system to enter new classes for an upcoming semester, cancel a class, and check conflicts in classroom/faculty assignments. Admissions use the registration system to add new students. Enrolment services use the registration system to report on retention, update student information, and check fulfilment of graduation requirements for those students planning to graduate.
39

40

What Is an Activity Diagram?


An activity diagram in the use-case model can be used to capture the activities in a use case. It is essentially a flow chart, showing flow of control from activity to activity.
Flow of Events This use case starts when the Registrar requests that the system close registration. 1. The system checks to see if registration is in progress. If it is, then a message is displayed to the Registrar and the use case terminates. The Close Registration processing cannot be performed if registration is in progress. 2. For each course offering, the system checks if a professor has signed up to teach the course offering and at least three students have registered. If so, the system commits the course offering for each schedule that contains it.

41

What Is an Activity State?


An activity state is an ongoing nonatomic execution that
Can be decomposed. May be interrupted and take some time to complete.

An activity state represents the performance of an activity or step within the workflow.

42

Example: Activity Diagram


Decision
[ add course ]

[ delete course ]

Delete Course

Activity State

Select Course

Synchronization Bar (Fork)


Check Schedule

Concurrent threads

Check Pre-requisites

Transition Guard Condition Synchronization Bar (Join)

[ checks completed ]

[ checks failed ]

Assign to course
[ student added to the course ]

Resolve conflicts

Update schedule

43

Swimlanes
Sales Fulfillment

Determine Need

Take Order

Fill Order Setup Payment

Deliver Order

44

Objectives
Describe dynamic behavior and show how to capture it in a model. Demonstrate how to read and interpret
a collaboration diagram. a sequence diagram.

Explain the similarities and differences between collaboration and sequence diagrams.

45

Objects Need to Collaborate


Objects are useless unless they can collaborate to solve a problem.
Each object is responsible for its own behavior and status. No one object can carry out every responsibility on its own.

How do objects interact with each other?


They interact through messages.

46

Objects Interact with Messages


The UML says: A message is the specification of a communication among objects that conveys information with the expectation that activity will ensue.
A message says how one object asks another object to perform an operation.

47

What Is an Interaction Diagram?


An interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them. It models the dynamic aspects of a system.

Sequence Diagrams

Collaboration Diagrams

48

What Is a Sequence Diagram?


A sequence diagram is an interaction diagram that emphasizes the time ordering of messages. The diagram shows
The objects participating in the interaction. The sequence of messages exchanged.

Sequence Diagrams
49

Example: Sequence Diagram


:RegisterForCoursesForm

: Student

: :RegistrationController

: :CourseCatalogSystem : Course Catalog

1: create schedule( ) 2: get course offerings( ) 3: get course offerings(forSemester) 4: get course offerings( ) 5: display course offerings( )

6: display blank schedule( )

50

Sequence Diagram Contents: Objects


: :RegisterForCoursesForm : :RegistrationController SWTSU Catalog : CourseCatalogSystem

Anonymous Objects

Named Object Lifelines

51

Sequence Diagram Contents: Actor


:RegisterForCoursesForm : Student :RegistrationController SWTSU Catalog : CourseCatalogSystem : Course Catalog

Actor instances

52

Sequence Diagram Contents: Messages


:RegisterForCoursesForm : Student 1: create schedule( ) 2: get course offerings( ) 3: get course offerings(for Semester) 4: get course offerings( ) SWTSU Catalog : : :RegistrationController CourseCatalogSystem : Course Catalog

5: display course offerings( )

Reflexive Messages

Message
6: display blank schedule( )

53

Sequence Diagram Contents: Focus of Control


:RegisterForCoursesForm : Student 1: create schedule( ) 2: get course offerings( ) 3: get course offerings(forSemester) 4: get course offerings( ) 5: display course offerings( ) SWTSU Catalog : :RegistrationController CourseCatalogSystem : Course Catalog

6: display blank schedule( )

Focus of Control

54

What Is a Collaboration Diagram?


A collaboration diagram emphasizes the organization of the objects that participate in an interaction. The collaboration diagram shows:
The objects participating in the interaction. Links between the objects. Messages passed between the objects.

Collaboration Diagrams
55

Example: Collaboration Diagram


5: display course offerings( ) 6: display blank schedule( )

1: create schedule( ) : RegisterForCoursesForm

: Course Catalog

: Student

2: get course offerings( ) 4: get course offerings( ) 3: get course offerings(forSemester) : RegistrationController : CourseCatalogSystem

56

Collaboration Diagrams Contents: Objects

: RegisterForCoursesForm

Objects

: RegistrationController

SWTSU Catalog : CourseCatalogSystem

57

Collaboration Diagram Contents: Actors

: RegisterForCoursesForm

: Student : Course Catalog

: RegistrationController

SWTSU Catalog : CourseCatalogSystem

58

Collaboration Diagram Contents: Links and Messages

5: display course offerings( ) 6: display blank schedule( )

1: create schedule( ) : RegisterForCoursesForm

: Course Catalog

: Student

2: get course offerings( ) 4: get course offerings( ) 3: get course offerings(forSemester) : RegistrationController : CourseCatalogSystem

59

Sequence and Collaboration Diagram Similarities


Semantically equivalent
Can convert one diagram to the other without losing any information

Model the dynamic aspects of a system Model a use-case scenario

60

Sequence and Collaboration Diagram Differences


Collaboration diagrams
Show relationships in addition to interactions Better for visualizing patterns of collaboration Better for visualizing all of the effects on a given object Easier to use for brainstorming sessions

Sequence diagrams
Show the explicit sequence of messages Better for visualizing overall flow Better for real-time specifications and for complex scenarios

61

Objectives
Describe the static view of the system and show how to capture it in a model. Demonstrate how to read and interpret a class diagram. Model an association and aggregation and show how to model it in a class diagram. Model generalization on a class diagram.

62

What Is a Class Diagram?


CloseRegistrationForm
- semester

Schedule

CloseRegistrationController

+ open() + close registration()

Student
+ get tuition() + add schedule() + get schedule() + delete schedule() + has pre-requisites()

+ commit() + select alternate() + remove offering() + level() + cancel() + get cost() + delete() + submit() + save() + any conflicts?() + create with offerings() + update with new selections()

+ is registration open?() + close registration() Professor


- name - employeeID : UniqueId - hireDate - status - discipline - maxLoad + submitFinalGrade() + acceptCourseOffering() + setMaxLoad() + takeSabbatical()

Static view of a system


63

Class Diagram Usage


When modeling the static view of a system, class diagrams are typically used in one of three ways, to model:
The vocabulary of a system. Simple collaborations. A logical database schema.

64

Example: Class Diagram


LoginForm RegisterForCoursesForm
RegistrationController

Schedule CloseRegistrationForm
CloseRegistrationController

Professor Student name address studentID Course CourseCatalogSystem BillingSystem CourseOffering

Is there a better way to organize class diagrams?


65

Review: What Is a Package?


A general purpose mechanism for organizing elements into groups. A model element that can contain other model elements.
University Artifacts

A package can be used:


To organize the model under development. As a unit of configuration management.
66

Example: Registration Package

Registration
CloseRegistrationForm
CloseRegistrationController

RegisterForCoursesForm

RegistrationController

67

What Is an Association?
The semantic relationship between two or more classifiers that specifies connections among their instances. A structural relationship specifying that objects of one thing are connected to objects of another.
<<entity>> Student <<entity>> Schedule <<entity>> Course

68

Example: What Associations Can You Find?


1: submit schedule( )
2: submit schedule( ) : RegistrationController

: Student
: Student

: RegisterForCoursesForm

8: any conflicts?( )

3: save( ) 4: submit( )

:Schedule

7: still open?( ) 9: add student(Schedule)

6: has pre-requisites(CourseOffering)

:CourseOffering :Student
5: is selected?( ) 10: mark as enrolled in( )

:PrimaryScheduleOfferingInfob

69

What Is Multiplicity?
Multiplicity is the number of instances one class relates to ONE instance of another class. For each association, there are two multiplicity decisions to make, one for each end of the association.
For each instance of Professor, many Course Offerings may be taught. For each instance of Course Offering, there may be either one or zero Professor as the instructor.
<<entity>> instructor Professor 0..1 <<entity>> CourseOffering 0..*

70

Multiplicity Indicators
Unspecified Exactly one Zero or more (many, unlimited)

1 0..* *

One or more Zero or one (optional scalar role) Specified range Multiple, disjoint ranges
71

1..* 0..1

2..4 2, 4..6

Example: Multiplicity
<<boundary>> RegisterForCoursesForm 1 1 0..1 <<control>>
RegistrationController

<<entity>> Student
1 0..*

<<entity>> 0..1 Schedule 0..*

<<entity>> CourseOffering
0..4

72

What Is Aggregation?
An aggregation is a special form of association that models a whole-part relationship between an aggregate (the whole) and its parts.
An aggregation is an is a part-of relationship.

Multiplicity is represented like other associations.


Whole 1
0..1 0..* Part

73

Example: Aggregation
<<boundary>> RegisterForCoursesForm 1 1 0..1 <<control>>
RegistrationController

<<entity>> Student
1 0..*

<<entity>> 0..1 Schedule 0..*

<<entity>> CourseOffering
0..4

<<entity>> Schedule 1 0..*

74

What Is Generalization?
A relationship among classes where one class shares the structure and/or behavior of one or more classes Defines a hierarchy of abstractions where a subclass inherits from one or more superclasses
Single inheritance Multiple inheritance

Is an is a kind of relationship

75

Example: Single Inheritance


One class inherits from another.
Ancestor
Account
- balance - name - number + withdraw() + createStatement()

Superclass (parent)

Generalization Relationship

Savings

Checking

Subclasses Descendents
76

Example: Multiple Inheritance


A class can inherit from several other classes.
FlyingThing
Multiple Inheritance

Animal

Airplane

Helicopter

Bird

Wolf

Horse

Use multiple inheritance only when needed and always with caution!
77

Review: An Object Has State


The state of an object is one of the possible conditions in which an object may exist. The state of an object normally changes over time.

Name: J Clark Employee ID: 567138 Date Hired: July 25, 1991 Status: Tenured Discipline: Finance Maximum Course Load: 3 classes

Name: J Clark Employee ID: 567138 HireDate: 07/25/1991 Status: Tenured Discipline: Finance MaxLoad: 3

Professor Clark

78

What Are Statechart Diagrams?


A statechart diagram shows a state machine. It specifies the sequence of states that an object can be in,
the events and conditions that cause the object to reach those states, and the actions that take place when those states are reached.

Sample State 1
79

Sample State 2

Drawing States
A state is represented as a rounded rectangle on a statechart diagram. As a comparison, note the subtle difference between a state versus an activity.
Sample State 1
Sample Activity

80

Special States
The initial state is the state entered when an object is created.
An initial state is mandatory. Only one initial state is permitted. The initial state is represented as a solid circle.

A final state indicates the end of life for an object.


A final state is optional. More than one final state may exist. A final state is indicated by a bulls eye.
Sample State 1 Sample State 2

81

What Are Events?


An event is the specification of a significant occurrence that has a location in time and space.
An event is an occurrence of a stimulus that can trigger a state transition. Example Adding a student to a course Creating a new course
Event State A State B

82

What Are Transitions?


A transition is a change from an originating state to a successor state as a result of some stimulus.
The successor state could possibly be the originating state.

A transition may take place in response to an event. Transitions can be labeled with events.
Event State A State B

Transition

83

Example: Statechart
Applied

[ accepted ] Enrolled

[ rejected ]
Freshman First year

[ credits >= 28 ] Sophmore Second year


[ credits >= 56 ] Junioryear Third Hiatus leave [ credits >= 84 ]

Senior year Fourth


return H

[ credits >= 112 ]

Graduated

84

What Is a Component Diagram?


A diagram that shows the organizations and dependencies among components.

85

What Is a Component?
A modular, deployable, and replaceable part of a system that encapsulates implementation and exposes a set of interfaces. It conforms to and provides the physical realization of a set of interfaces.

86

Example: Component Diagram

Component A Interface

Component B

87

What Is a Deployment Diagram?


The deployment diagram shows the
Configuration of processing nodes at run-time. Communication links between these nodes. Component instances and objects that reside on them.

88

What Is a Node?
Physical run-time computational resource Types
Processor Node <<Node>> Node #1 Executes system software Device Node Support device Typically controlled by a processor

89

What Is a Connector?
Connection
Communication mechanism Physical medium Software protocol
<<Processor>> Processor #1

Connection

<<Device>> Device #1

90

Example: Deployment Diagram


Desktop PC Desktop PC

<<Campus LAN>> <<Campus LAN>>

Registration Server

<<Campus LAN>>

<<Campus LAN>>

<<legacy>> Course Catalog

<<legacy>> Billing System

91

Questions

92

Thank you

93

Вам также может понравиться