UML 1.5 Unified modeling Languageimg1.tapuz.co.il/communafiles/3179554.pdf · Unified modeling...

59
UML 1.5 Unified modeling Language Presented by Gal Amram 01 Jun 2004

Transcript of UML 1.5 Unified modeling Languageimg1.tapuz.co.il/communafiles/3179554.pdf · Unified modeling...

UML 1.5Unified modeling Language

Presented by Gal Amram01 Jun 2004

Table of Content1. An Introduction to UML.2. UML Diagrams:

1. Use Case.2. Activity.3. Package.4. Class.5. Object.6. Sequence.7. Statechart.8. Component.9. Deployment.

3. Summery4. Tools.5. Bibliography.

What is UML ?Unified - One common language to rule them all.Modeling - Depict the structure & behavior of a system. Language - A set of graphical notation and semantics. (Language not method)

Why use UML ?Team communication. (A picture is worth a thousand words)Work at different levels of a abstraction.Programming language is not high enough level of abstraction for design purposes.Separate system design from system implementation.

An Introduction to UML.

UML Diagrams.

Diagram

StructureDiagram

BehaviorDiagram

Class Diagram

ComponentDiagram

ObjectDiagram

PackageDiagram

DeploymentDiagram

ActivityDiagram

Use CaseDiagram

State machineDiagram

Interaction Diagram

SequenceDiagram

CollaborationDiagram

Diagrams categorization: structural diagrams - static definition of the resources.behavioral diagrams - resources in motion.interaction diagram - emphasize object interactions.

Diagrams as point of view:Functional view – a view of an outsider.Static view – the blueprint.Dynamic view – the system in motion.

UML Architecture.

Four-Layer Metamodel Architecture:

1. Meta-Metamodel <- MOF Layer2. Metamodel <- UML Layer3. Model <- System Model4. Instance (Data) <- Running System

Extensibility mechanisms.Stereotypes - extends the semantics of the metamodel. << >>Tagged value - assign a feature to a model element in addition to those features already defined in the metamodel. {name = “value”,…}Constraints - Constraints define the invariants that preserve the integrity of the system. {OCL,…}

Stereotypes & Tags

Constraints

PersonCarown* 1

{ordered,valid registrationnumber, maxSpeed < 300 km/h}

<<interface>>Vehicle

{Creator="Tsunami",Updated="01/01/04",

Approved}Class

<<interface>>

<<utility>>Calculator

{Creator="Tsunami",Updated="01/01/03",

not-finished}<<utility>>

Analysis

Use Case Diagram

provide an external view of the relationship between the system and the outside world.Identify the roles in the system.Identify expectations from the system.Identify shared behavior among system features.Goal-focused modeling allow variety of different solution. (define the problem not solution)

Use case modeling elements:

Actor – a role played by an outside entity in our system.Use case – systems’ goals.Association - Interaction between actors and use cases.Include – reusable use case that is unconditionally part of another use case.Extend - reusable use case that is conditionally part of another use case.Generalization – inheritance between actors.

Customer

ClerkBranchManager

Login

Create Account

«extend»

ValidateOrderPlace

Order«include»

Update Order

«include»

Inventory Report

Orders Report

Produce Order Bill

Profit Report

«act»

«actor»System Scheduler

Customer

Create Account

Login

login failure

«extend»

extension use case

baseuse case

extension point

Activity DiagramRepresent the logic required to implement system behaviors.Represent logic at any level the design needs, from system workflow to individual method implementations.

Used to describe use case scenarios.Used for function modeling.GUI navigation.

Different scenarios for system behaviors.It translates quite well into pseudo-code.

Login User Name Prompt

/Submit

Create Account

[Invalid]

[Else]

Password Prompt

Report Login Error

[Success]

[User Existent]

Faliure

/Cancel

[Valid]

/Login

/Cancel

Design

Package Diagram

The package is the main construct in UML for grouping model elements. (folder, namespace)

Identify the data and functional dependencies between parts of a system.Identify the partitioning of a system into subsystems.Identify phases in a project.Separate utilities from system-specific components.Isolate layers of an architecture.

Rental SystemLogic

Rental SystemHTML GUI

Rental SystemJAVA GUI

Inventory ManagementSystem

Orders ManagementSystem

general grouping mechanism

Analysis Implementation

Design

ImplementationFile

Executable

HeaderFileUse Case Narrative

Use CaseDiagram

Use CaseScenario

ClassDiagram

InteractionDiagram

Class Diagram

Define the essential resources of a system.Define relationships between resources.Generate code (forward engineering).Model code (reverse engineering).Provide focus for other diagrams.

Class notation

Represents the resources of a subject area.Purpose drives the definition of an object.User-defined compartments.Level of abstraction.

Name Compartment

Attributes Compartment

Operations CompartmentList Compartment

Measuring Quality :Cohesion & Coupling

Cohesion measures two factors: how well-defined the purpose of the object is, and whether every part of the object contributes directly to fulfilling the purpose.Coupling is a measure of the degree of dependency between objects.

High cohesion & Loose coupling.

Attribute:[visibility] name [: type] [multiplicity]

[=default] [{property-string}]

Operation:[visibility] name ([parameter-list]): [return-result] [{properties}]

Visibility – private(-), package(~), protected(#), public(+) Type - Integer/String/Boolean/user~language specified.Multiplicity([1..16], [5…*], [2], {isOrdered})Underline Class-level operators and attributes. (static members)

RentalBranch

- profit : unsigned long- expense : unsigned long

+ place_order ( _ordr : Order ) : bool+ cancel ( _custID : int, _orderID : int ) : Order *

Order

- m_pCustomer : Customer * - m_pRentObj : RentObj *- m_pickupDate : Date {>= current date}- m_returnDate : Date- m_pickupBranchCode : int- m_returnBranchCode : int- m_isInsurance : bool = false

- orderCount : int = 0

+ validate ()+ open ()

1

*{ordered by date}

Object Relationships notation.Association.

Generalization.

Dependency.

Person

Vehicle

Car

Carinherit

Driver Vehicle

own

is owned

depend

Association

Refinement

Composition

each part may only be a member of one aggregate object.

Aggregation

protect integrity of the configuration.function as a single unit.

control through one object - propagation downward.

Association

Objects are aware of one another so they can work together

PersonCar

Employee

Design_Team

EngineCar

Analysis_Team

own* 1

1 0..1

0..1

*

*0..3

Generalization Concepts:

Generalization - organizing the properties of a set of objects that share the same purpose.

Generalization. Inheritance.Specialization.

SuperClass.SubClass.Abstract class.Concrete class.Discriminator

Generalizationsuperclass

specializationsubclass

Inheritance

Abstract_User

- m_password : string- m_userID : string- m_userType : int

Clerk

ServiceClerk Customer

BranchManager

<<enum>>USER_TYPE

CUSTOMERCLERKSERVICE_CLERKBRANCH_MANAGERCHAIN_MANAGER

ChainManager

I_Reports

Abstract class notation.

Vehicle

Vehicle

+ accelerate () {abstract}

{abstract}Vehicle

Vehicle

+ accelerate ()

Dependency Order

- m_pCustomer : Customer * - m_pRentObj : RentObj *- m_pickupDate : Date {>= current date}- m_returnDate : Date- m_pickupBranchCode : int- m_returnBranchCode : int- m_isInsurance : bool = false

- orderCount : int = 0

+ validate ()+ open ()

Order Date

Polymorphism via Generalization.

Vehicle

+ accelerate (){abstract}

Car

+ accelerate ()

Truck

+ accelerate ()

Polymorphism via Realization.Implementing an interface class is called realizing the interface class.

<<interface>>Product

+ buy ()+ sell ()+ price () : real

Car Book Music_cd

Object Diagram

Support the investigation of requirements by modeling examples from the problem domain. Model test cases to validate the Class diagram.

Object (not class), Link (not association)

Class –- association -– ClassObject –- link -- Object

Object-Name : Class-Name

: Class-Name anonymous object

Object-Name

myHonda : Car

- brand = "Honda"- model = "65DX"- licence_number = "87-45-34"- year = 1977

Tsunami : Person

Name = "Tsunami"Address = "23 nowhere St."IdNumber = 12345

Own

myJeep : Car

- brand = "Jeep"- model = "0.01"- licence_number = "78-54-43"- year = 1988

Own

Sequence Diagram

Illustrate interactions between objects.Have a narrow focus. (single scenario)Explicitly identify the communication required to fulfill an interaction. This helps validate or discover the interfaces required by a class.

Customer

Order

Branch

get_data()

new_order()

init_content(data)

place_order(order)

validate()

bool

status

«interface»RSA:Cipher :OutBox:Email

0:send()

1:encrypt(self)

2:ciphertext

3:send (self)4:return

:OutBox :Socket

6:send(content)

10:status

1*[forever]:ProcessMsg

7:status

: Email

8:delete()

outgoing : Queue

2:pullQueue()

5:Email

:Mutex

3:lock()

:OutBox :Socket

1*[forever]:ProcessMsg

: Emailoutgoing : Queue

2:pullQueue()

:Mutex

3:lock()

4:exception(error:string)

Statechart Diagram.The Statechart models the events that trigger a transition (change) from one state to another state. (change state when behavior changes)

Identify the specific responses of an object to everything that can happen to the object.Identify what events an object will and will not respond to depending on its current state.Discover or validate the data needed to define the state of the object and the attributes affected by the change.Help discover the internal effects of behaviors.

Places in Branch

Entry/validate()Entry/update_order_status()

Allocated

Do/update_order_data()

Deleted

Cancel()

submit()

update()

in progress

Entry/update_order_status()

execute()

[car returned & bill paid]

Closed

Summary

UML is not so much a new concept as it is the gathering together of many tried and true modeling techniques from mature development methods. UML is designed specifically to represent object-oriented systems.Each diagram reveals a unique yet overlapping view of a system - Each diagram describes the problem in a different way.

Tools

MagicDraw. http://www.magicdraw.com/

Pacestar UML Diagrammer. http://www.pacestar.com/uml/

MS-Visio. http://www.microsoft.com/office/visio/

Bibliography

Tom Pender. UML Bible, John Wiley & Sons. [2003]Martin Fowler. UML Distilled: A Brief Guide to the Standard Object Modeling Language, Third Edition. [2003]Arthur J Riel. Object-Oriented Design Heuristics. [1996]

The End

Application Architecture

Artifacts

A physical piece of information that is used orproduced by a software development process. Examples of artifacts include models, source files, scripts, and binary executable files.

Component DiagramDepict The physical description of the software.provides an encapsulated view of the functionalitydefined by the contained classes.

Model the real software in the implementation environment.Provide an accurate picture of existing systems prior to making changes or enhancements.Reveal bottlenecks in an implementation without forcing you to read all of the code.

Component stereotypes:«executable»: A component that runs on a processor.«library»: A set of resources referenced by an executable during runtime.«table»: A database component accessed by an executable.«file»: Typically represents data or source code.«document»: A document such as a Web page.

«Distributed Object»Email

«Dynamic Library»Encryption

POP3_Connection

«Dynamic Library»Network

«DLL»NetWork

«becomes»

artifact component classes

Socket

POP3

HTTP

«contain»

«contain»

«contain»«library»Network

Network

Socket

POP3 HTTP

Deployment Diagram

Depict The physical devices that run the system.

Model the hardware platform for a system.Identify hardware capabilities that affect performance planning and software configuration.

Client

FireWall

FTP Server

Datebase

Web Server

EmailServer

*

1

1

1

1 *

*

*

*

*

*

*

«Ethernet»

«PPP»

Type level

Instance level

Everest : HP ServerTsunami : Desktop

Email

POP3 Protocol

Email Server

«HTTP»

POP3 Protocol

HTML Content Web Server

Event-name (Param-list)[guard-condition]/action-expression

Allocated

Sending

send() [dest = valid email addr]

sent()/nofityOutbox()

when(not connected)

after(30 min)pause

sent

Allocated

Sending

entry/updateSendDate()entry/updateSendTime()

send() [dest = valid email addr]

sent()/nofityOutbox()

Stop

exit/connect)

sent

when(not connected)

after(30 min)