uml

49
1 Unified Modeling Language Overview 1. Object-orientation: Terms and concepts. 2. Use Cases: Requirements model 3. Class Diagram: The static model 4. Behavioral Modeling: The four dynamic diagrams 5. Implementation: The two physical models

Upload: ashish-jha

Post on 06-May-2015

1.014 views

Category:

Education


0 download

TRANSCRIPT

Page 1: UML

1

Unified Modeling Language Overview

1. Object-orientation: Terms and concepts.

2. Use Cases: Requirements model

3. Class Diagram: The static model

4. Behavioral Modeling: The four dynamic

diagrams

5. Implementation: The two physical

models

Page 2: UML

2

Introduction

Object-Oriented (O-O) systems development is a way to develop software by building self-contained modules that can be more easily: Replaced Modified and Reused.

Page 3: UML

3

Transitioning to Object-Orientation

Functional Decomposition vs. Object-Orientation

• Focus on verbs• Focus on process• Describe interactions• Vague partitioning

rules• Analysis and design

separate

•Focus on nouns•Focus on behavior•Describe messages•Rules on encapsulation•Analysis and design

blend

Page 4: UML

4

Object-Oriented Terms Object: Anything that

models “things” in the real world. These “things” may be physical entities such as airplanes, or events such as a conference, or abstractions and logical concepts.

An object is an instance of a class.

Class: A template that defines the structure and capabilities of an object instance. The class definition includes the state data and the behaviors (methods) for the instances of that class.

Abstract class: A class that can only be used as the base class of some other class. (e.g. Geometric Shape vs. Circle).

Page 5: UML

5

Object-Oriented Terms (cont.)

Attribute: Classes use attributes to store information about themselves (state information).

Operation: An action or transformation that a class performs or is performed on a class.

Method: Internal implementation of an operation for a specific object.

Service: Just a kind of method, but provides access to related functions sharing some common purpose.

Page 6: UML

6

An Example of a Class

Employee

NameDateOfBirthHomePhoneNoTitle(etc.)

listDepartmentsWorked()assignToSupervisior()computeVacation()listEmployees()(etc.)

Class Name

Attributes

Operations

Page 7: UML

7

Object-Oriented Properties

Inheritance: Parent/Child relationship among classes. A subclass inherits all attributes and behavior of the superclass.

Polymorphism: A request-handling mechanism that selects a method based on the type of the target object.

Encapsulation: The act of grouping both data and methods into a single object .

Information Hiding: Objects hide their internal structure from their surroundings.

Page 8: UML

8

Object-Oriented Properties (cont.)

Page 9: UML

9

Eight (or Nine, or Ten) UML Diagrams

1. Use-case diagramRequirements

Behavioral view (dynamic)

3. Sequence diagram (an OID)4. Collaboration diagram (an OID)5. State Chart diagram6. Activity diagram

Implementationview

7. Component diagram8. Deployment diagram

Organize Models 9. Package10. Object diagram

Static view 2. Class diagram

Class Instances Model

Page 10: UML

10

Use Cases Use cases are graphical scenarios

for understanding system requirements.

A textual scenario accompanies each use case.

A use case is a specific interaction between users (actors) and some system functionality.

The use-case model captures the goal of the user and the responsibility of the system to its users.

Library System

Check out books

Read books,NewspapersMember Supplier

Purchase Supplies

GetInterlibrary loan

Page 11: UML

11

Class Diagram

The UML class diagram is the static analysis and design diagram.

Class diagrams show the static structure of the model.

The class diagram is collection of static modeling elements, such as classes and the relationships among the data.

Page 12: UML

12

Class Diagrams (cont.)

Boeing 737

length: meter fuelCapacity: Gal doors: int

lift ( )roll ( )

Boeing 737

Boeing 737

length: meter fuelCapacity: Gal doors: int

In class notation, either or both the attributes and operation compartments may be suppressed.

thrust ( )

Page 13: UML

13

Object/Class Relationships

Three types of relationships among classes (or among objects, for that matter) are: Association. Generalization. Aggregation (consists of).

Composition (a-part-of).

A Stronger Aggregation

Page 14: UML

14

UML Association Notation

In the UML, a navigable association is represented by an open arrow.

BankAccount Person

BankAccount Person

A bidirectional association does not have an arrow.

Page 15: UML

15

UML Binary Association Notation

A binary association is drawn as a solid path connecting two classes or both ends may be connected to the same class.

Company PersonWorks For

employer employee

Person

Married To

Note:•Association Name•Association Roles

Page 16: UML

16

Qualifiers and Multiplicity

A qualifier is an association attribute. Account# is an attribute of Bank, but is important enough to note as the qualifier in the association.

Multiplicity specifies the range of allowable associated classes.

Bank

Person

accountNo

0..1

*

.

Page 17: UML

17

UML Association Class

An association class is an association that also has class properties.

An association class is shown as a class symbol attached by a dashed line to an association path.

WorksFor

Personemployer employee

Company

salary

Page 18: UML

18

UML N-Ary Association

An n-ary association is an association among more than two classes.

The n-ary association is more difficult to understand. It is better to convert an n-ary association to binary association.

GradeBook

Studentclass

Class

gradeexamlab

Year

semester

*

*

*

student

Page 19: UML

19

Generalization Relationships

Generalization is a form of association. Sub-classes are specialized versions of their super-

classes.

Vehicle

Bus Truck Car

Boeing 737

BoeingAirplane

Boeing 757 Boeing 767

Shared target style

Separate target style

Page 20: UML

20

Aggregation Relationships

Aggregations are a-part-of relationships, where a class consists of several component classes.

Aggregation is a special form of association.

Playerclass

Team1 *Consists Of

Page 21: UML

21

UML Composition

Compositions are aggregations with strong ownership. They use solid diamonds. When the composition dies, all components die too.

Car

4

Wheel Light Door Engine

4, 10 2, 5

1

1

11 1

nested composition

graphical composition

Wheel 4

Door 2,5

Engine 1

Car

4,10Light

Page 22: UML

22

Object Diagram

The UML object diagram is the static analysis and design diagram using specific, named objects.

Object diagrams follow the same rules as class diagrams.

The object diagram may be used to model a concrete instance of a use case. It helps understand the emerging system model. After it is abstracted into a class diagram, it may be

discarded.

Page 23: UML

23

Four UML Behavior Diagrams

1. Sequence diagram (an OID*)2. Collaboration diagram (an OID*)3. State Chart diagram4. Activity diagram

•Behavioral (dynamic) models reflect system processes over time.

*Object Interaction Diagram

Page 24: UML

24

Sequence Diagram A sequence diagram shows an interaction arranged in a

time sequence.

Telephone Call

dialTone( )

:Exchange :Receiver:Caller

offHook( )

ringTone( )dialNumber( )

:Talk

offHook( )

onHook( )breakConnection( )

onHook( )

Page 25: UML

25

Collaboration Diagram

A collaboration diagram shows process interactions and messaging.

ATM Machine:Definition

Checking Account

Account Bank Client

5: Process Transaction

8: Transaction succeed

4: Enter Amount

13: Terminate

1: Request Kind

2: Enter Kind

3: Request Amount9: Dispense Cash10: Request Take Cash11: Take Cash12: Request Continuation14: Print Receipt

7: Withdraw Successful 6: Withdraw Checking Account

Page 26: UML

26

UML Statechart Diagram

A UML statechart diagram shows the change in states that an object encounters during its life as it responds to outside stimuli and messages.

Statecharts are good for showing complex state behavior of some objects.

Statecharts are often seen in real-time or embedded system modeling. User Interface navigation can employ statecharts.

Page 27: UML

27

Idle lift receiver andget dial tone

Idle State

Dialing Substates

Dialing

Start Dial

entry and start dialogexit / stop dial tone

entry and num.append(n)

digit(n)

num.isValid( )

Page 28: UML

28

UML Activity Diagram

An activity diagram is a variation or special case of a state machine.

The states are activities representing the performance of operations.

The transitions are triggered by the completion of the operations.

Activity diagrams are easily confused with traditional flow charts but can show synchronous events.

Page 29: UML

29

Activity Diagram with Swimlanes

Office Clerk Insurance Agent Loan Officer

Edit Incoming

Paper

CompleteRequest

Check Life insurance Draw Up

Deed

Calculate Mortgage

Pay Provision to Agent

Write Insurance

Policy

Indexdocuments

Page 30: UML

30

Component diagrams

UserInterface

UpdateAccess

• Packages the logical view. Component diagrams show the structure (libraries) of the code itself.

Page 31: UML

31

Deployment Diagram

Node 1: AdminServer

Node 2: John’s PC

U I

UpdateAccess

• Packages the implementation view. Deployment diagrams show the structure (hardware) of the run-time system.

Page 32: UML

32

A Package and Its Contents

GradeBook

Studentclass

Class

gradeexamlab

Year

semester

*

*

*student

GradeNoteBook

• Used for model management, a package is a grouping of model elements and may contain other packages.

Page 33: UML

33

Notes in UML

A note is a graphic symbol containing textual information that might be anchored.

It also could contain embedded images.

Representsan incorporatedentity

Person Companyemployee employer

Static models &revision levels

released yesterday

Page 34: UML

34

Recap: The UML Diagrams

1. Use-case diagramRequirements

Behavioral view (dynamic)

4. Sequence diagram (an OID)5. Collaboration diagram (an OID)6. State Chart diagram7. Activity diagram

Implementationview

8. Component diagram9. Deployment diagram

Organizing the Model

10.Package

Static view 2. Class diagram3. Object diagram

Page 35: UML

35

Recap: The UML Diagrams

1. Use-case diagramRequirements

Behavioral view (dynamic)

3. Sequence diagram (an OID)4. Collaboration diagram (an OID)5. State Chart diagram6. Activity diagram

Implementationview

7. Component diagram8. Deployment diagram

Organize Models 9. Package10. Object diagram

Static view 2. Class diagram

Class Instances Model

Page 36: UML

36

Diagrams in View Context

Structural View

Implementation View

User View

Behavioral View

Environment View

Class Diagrams

Object Diagrams

Sequence Diagrams

Collaboration Diagrams Statechart

Diagrams Activity Diagrams

Component Diagrams

Deployment Diagrams

Use Case Diagrams

Page 37: UML

37

A Very Few Resources

Books (UML only)

Page-Jones, Meilir (2000). Fundamentals of Object-Oriented Design in UML. Addison-Wesley.

Taylor, David (1992). Object-Oriented Technology; A Manager's Guide. Addison-Wesley.

Web Sites

IBM / Rational Software. UML resource center. http://www-306.ibm.com/software/rational/uml/

The Object Mangement Group. UML resource page. http://www.omg.org/technology/uml/

Page 38: UML

38

Typical UML Models/Diagrams

• Class Diagram - Describes the logical structure of the architecture by showing the types of classes that constitute the system and their interrelationships. A class represents a set of logical objects that share the same attributes and behavior.

• Use Case Diagram – Describes the required functionality of the system in terms of goals that provide an observable result of value or service to actors.

• Activity Diagram – Describes, in a workflow format, the activities and decisions required by a system to achieve the goal of an associated use case.

• Statechart Diagram - Describes the states of a system across the system’s lifecycle (may show the affects of several use cases). It shows the transition from state to state in response to an event.

• Sequence Diagram – Describes how the sequences of activities are controlled by the objects’ interactions. In particular, they show the objects participating in the interaction and the time sequence of messages exchanged.

The SoSE modeling suite will be used by the System Architecture Team to capture the system requirements and architecture for system development. The SoSE modeling suite will be used by the System Architecture Team to capture the system requirements and architecture for system development.

Page 39: UML

39

<Class Name C><Class Name B>+C to B

+B to C

Actor Name A

+B to A

+A to B

SoS Level

Class Diagram Format

actor class interface

relationship

system class boundary

system class

System Class: An abstract representation of the SoS, System, Subsystem or Configuration Item (e.g., a class of ship, airplane, truck, satellite, HWCI, or CSCI).

Actor Class: An abstract role represented by an individual or a group of individuals, organizations, or external systems that interact with the system class.

system class

Page 40: UML

40

<Use Case Name B>Actor Name A

SoS Level

Actor and Use Case Format

actor class value or

service relationship

use case

system boundary

Use Case Name should be a statement of the goal (or service) desired by the actor expressed as an active verb and a quantifiable noun (e.g., start engines and maneuver satellite).

Page 41: UML

41

Use Case Diagram Example

Sustain SoS

Monitor Area

<<include>>

Assess Reports

<<include>>

Plan Tasks <<include>>

Execute Plan

<<include>>

Regional Commander

Military SoS

Regional Commander

Page 42: UML

42

Actor Action Activity A

Activity B

Activity D

Activity C

: <Class Name C> : <Class Name B> : <Actor Name>

Activity Diagram Format

activity

stop

actor action

classes

activity flow path

start

swim lanes

Page 43: UML

43

Activity Diagram Example for Monitor Area Use Case

Commander's Tasking

Create Sensor Task Plan

Task Sensors

Process Sensor Reports

Create and Send AWACS Sensor Reports

Configure AWACS Sensors

Launch AWACS

: AWACS : Mobil Command Center (MCC) : Regional Commander: Regional Commander : Mobil Command Center (MCC)

: AWACS

Page 44: UML

44

<State Name Alpha>

<State Name Bravo>

Event 2Event 1 Event 3

State Chart Diagram Format

start

state

transition

stop

transition transition

state

Page 45: UML

45

State Chart Diagram Example

Startup

Surveillance

Planning

Engagement

Sensors Tasked

Target Reported

Course of Action DeterminedTarget Report

MissionCompleted

Mission Initiated

Page 46: UML

46

: System Level Class Alpha

: System Level Class Bravo

: System Level Class Charlie

: Actor Class

Action

Interaction A

Interaction B

Interaction C

Interaction D

Response

Sequence Diagram Format

Interactions

actor initiates action

classes

actor receives response

Page 47: UML

47

Sequence Diagram Example

: Regional Commander

: AWACS : Satelllite : Mobil Command Center (MCC)

: UCAV

Operation Plan

Schedule Satellite

Prepare Air Tasking Order

Air Tasking Order

Air Tasking Order

Satellite Data

AWACS Reports

Evaluate Data and Reports

Situation Report

Evaluate Operation Plan

UCAV Data

Page 48: UML

48

: System Level Class Alpha

: System Level Class Bravo

: System Level Class Charlie

: Actor Class

2: Interaction A

5: Interaction D

3: Interaction B4: Interaction C1: Action6: Response

Collaboration Diagrams Format

actor initiates action

actor receives response

interactions

Page 49: UML

49

Collaboration Diagram Example

: Regional Commander

: Mobil Command Center (MCC)

: AWACS : Satelllite

: UCAV

2: Evaluate Operation Plan4: Prepare Air Tasking Order

10: Evaluate Data and Reports1: Operation Plan

11: Situation Report

3: Schedule Satellite7: Satellite Data

5: Air Tasking Order

6: Air Tasking Order

9: AWACS Reports

8: UCAV Data

: Regional Commander