Sie sind auf Seite 1von 35

Prepared by Jayashree Kar July 2004, Wipro Technologies

UML Diagrams for Designers


Prepared by: Jayashree Kar Architect, Corporate Vertical Wipro Technologies Aug, 2004

P R E S E N T A T I O N B Y W I P R O T E C H N O L O G I E S

What is UML?
UML stands for Unified Modeling Language. UML is a set of standard notations used for modeling object oriented systems. UML has evolved through the work of Grady Booch, James Rumbaugh, Ivar Jacobson and Rational Software Corporation. UML helps to specify, visualize and document models representing systems. UML is a industry standard for modeling application systems. UML model is methodology independent; i.e. UML can be mapped for all the widespread

methodologies.
UML model can platform independent. UML model be either Programming language specific or independent.. UML has been accepted by Object Management Group (OMG) as the standard for modeling OO systems. UML is the foundation of OMGs model driven architecture (MDA). be either hardware and software platform specific or hardware and software

23 Jun 2004

Wipro Confidential

Why UML Modeling?


Modeling is a highly creative process through which a solution is created iterating through the requirements. Provides standardization of models across the industry. Provides common language to Architects, developers and business users. Human brain is more receptive to pictures than texts; hence models convey lot more than pages of text. Modeling is essential part of large projects and is useful for small and medium size projects.

UML provides support in each phase of OOAD software life cycle.


Provides support for taking a holistic view of the system through the various models representing logical, implementation, deployment, process and use case views. Supports model driven architecture (MDA). Enhances speed of project by providing code generation from the model. Reverse engineering features of the modeling tool helps in understanding the existing systems. Has support for platform specific (PSM) as well as platform independent models (PIM)

23 Jun 2004

Wipro Confidential

UML: Various Views


Contains components, APIs etc Implementation view is for component designers

Implementation view

Contains system boundary, use cases, actors etc.

Contains classes, interfaces, etc. Logical view is for product designers

Logical view

Use case view

Deployment View

Contains node, network connectivity etc. Deployment view is for system administrators

Use case view is for all the stakeholders of the system

Process View

Contains processes, activities etc. Process view is for business owners


23 Jun 2004

Wipro Confidential

UML Diagrams - Overview


UML defines Nine types of standard diagrams. They are as follows:
Structural diagram Class Object Component Deployment Behavioral diagram Use case Sequence Collaboration Activity State-chart In addition, the following are used for model management: Model Management diagram Package Subsystem Model

23 Jun 2004

Wipro Confidential

UML Diagrams
Structural Diagram
UML Diagram Class Object Description This is the most important diagram in OO design. It represents the static behavior of the system. These describe the static structure of a system at a particular time. This is used for modeling the pilots projects. This is also used for validating the model. These diagrams describe the organization of physical software components, including source code, run-time (binary) code, and executables. This diagram provides overview of various separable pieces. These diagrams depict the physical resources in a system, including nodes, components, and connections. This is used by the systems administrator who install and/or maintain the systems. This is used to depict the disaster recovery sites and alternate sites as well.

Component

Deployment

23 Jun 2004

Wipro Confidential

UML Diagrams
Behavioral Diagram
UML Diagram Use case Description This is the most important model used for the Object oriented analysis. This denotes functionality of system using actors and use cases. This is also used for understanding the boundary of the system. diagram This is used for modeling the dynamic behavior of the system. This is used to describe interactions among classes in terms of an exchange of messages over time.

Interaction (Sequence)

Interaction (Collaboration)

diagram

Collaboration diagrams represent interactions between objects as a series of sequenced messages. Collaboration diagrams can describe both the static structure and the dynamic behavior of a system. Most of the tools can convert sequence diagram to collaboration and vice versa.
These diagrams describes the dynamic behavior of a system in response to external events. This diagram is created for the state machines implemented by the system. This is also useful in modeling reactive objects whose states are triggered by specific events. These diagrams illustrate the dynamic nature of a system by modeling the flow of control from activity to activity. An activity represents an operation on some class in the system that results in a change in the state of the system. Typically, activity diagrams are used to model workflow or business processes and internal operation. Swim lanes in activity diagram are used to denote segregation of processes conducted by various organizations.

State machine

Activity

23 Jun 2004

Wipro Confidential

UML Diagrams
Model Management Diagram
UML Diagram Package Description This is used to organize elements of a system into related groups to minimize dependencies between packages. Package diagram can be used with class diagrams to logically group the classes. They are also used to group the use cases. This helps to manage the system and the model. Model properties help understand the model items properly.

Subsystem Model

23 Jun 2004

Wipro Confidential

Extending UML Notations


UML notations can be extended to be used in different situations
UML Diagram Notes Description Notes are used to add explanatory description to any of the elements in UML
UML defines nine types ...

Note Anchor Stereotypes

To attach the note to the UML element it is attached A stereotype extension mechanism is used to define a new kind of model element based on the existing model element. Stereotypes are denoted as <<stereotypename>> Properties can be attached to UML elements in the form of namevalue pair . These properties are called tagged value. Constraint is a restriction attached to an UML element that limits the usage of the element or the semantics of the element.

Tagged value

Constraints

23 Jun 2004

Wipro Confidential

Class Diagram/ Package Diagram


Class diagram is the most important class for representing logic model of the system
Symbols/ Notation class Description A class is represented by symbol. It denotes a particular type of Objects. It has attributes and operations that define the Property of the class. A package is represented by the symbol.
Ins urance

Package

It denotes a logical Group of classes. Since the visibility of class, its attributes And operations can be defined at package level, proper Package definition is important to reduce dependencies. Association Association is represented by a line with arrowhead. It denotes conceptual relationship between two classes. A class may have some attributes due to its association with the other class. The association can be attached to a class; called association class
C1 C2

Aggregation

Aggregation is a special type of association where the one class forms the part and the other forms the whole. In aggregation relationship, the parts are shared across wholes.
House Window

Cardinality/ Multiplicity

Multiplicity is used with associations to represent how the objects are related. Associations can be mandatory, optional, many to many, one to many etc.
House 1..n Window

23 Jun 2004

Wipro Confidential

10

Class Diagram/ Package Diagram


Class diagram is the most important class for representing logic model of the system
Symbols/ Notation Composition Description Composition is very similar to aggregation and associates part and whole classes but here the whole class takes care of creating and destroying the part hence the part is not shared. Car Engine
(from policy) 1 (from policy)

Active classes

Active class is a special type of class that owns an execution thread to initiate control activity. It executes itself concurrently till it is completed/ terminated by an external force. Passive class has instances that can execute only when another class performs some operation on it. It is either implemented by a process or a thread. If a class is specialized that means it is inherited from a generalized class. A corporate customer is a specialization of customer class where it inherits the properties (attributes and operations) and can have extra properties of its own. It can override some of the properties as well.

Generalization/ Specialization

Dependency

In this the dependent class changes when the class it is depending upon, changes.
EventBufferList (from data) BufferConfiguration (from data)

Visibility

The attributes and operations in a class can be private, public or protected. Depending upon the type the property has visibility to the outside world.
Wipro Confidential

23 Jun 2004

11

Class Diagram/ Package Diagram


UML notations can be extended to be used in different situations
Symbols/ Notation stereotypes Description Stereotypes are used extensively in the class diagrams to denote various type of objects such as DB tables, XML elements, EJB components etc.
<<thread>> Class

Interfaces

These are consists of constants and method descriptions that a class or a set of class would like to expose to the world.
Interface

23 Jun 2004

Wipro Confidential

12

Class Diagram/ Package Diagram


Aggregation

Attribute Generalization/ Specialization Operation

Association Multiplicity/ cardinality

23 Jun 2004

Wipro Confidential

13

Class Diagram/ Package Diagram

Presentation Layer

Package

Application Layer

link

Domain Layer

23 Jun 2004

Wipro Confidential

14

Object diagram
Models the static behavior of the system Used for modeling pilot projects or validating the models
Symbols/ Notation object Object attribute Object operation Others Description This is an instance of the class. Graphically it is represented the same way as the class with instancename:classname. This is used to represent the attributes at the object instance level. This is used to represent the operations at the object instance level. The notations used for drawing class diagram is used in the object diagram as well.

23 Jun 2004

Wipro Confidential

15

Use case diagram


Used for representing functional model of the system
Symbols/ Notation System scope Description This is represented by a rectangular hollow box. This is used to define the boundary of the system. This is represented by an ellipse shape. This is used to represent a set of transactions that provides some tangible value to the actors.
Maintain System

Use case

actor

An actor is represented by a stick man. An actor interacts with the use case to get some tangible value from the system.
end us er

Links

Actors are linked with the use cases when either they contribute to the use case or get some benefits from the use case. Use cases are linked with other use cases via includes and extends relationship.

Includes
Extends

If some functionality is common to multiple use cases then it can be separated as a use case and denoted by <<includes>> stereotype.
If there are two use cases in which one use case has a special type is functionality extending the other use case then it is represented by using extension point and denoted by <<extends>> stereotype. Packages are used to group the use cases. Package is represented as
Ins urance

Packages

23 Jun 2004

Wipro Confidential

16

Use case diagram


Association Insurance system

Customer

Read Purchase Policy

Salesman

Actor Actor
Can be any type of customer

Notes

Use case
Analyze Sales Statistics Insurance system

Package

System scope

23 Jun 2004

Wipro Confidential

17

Use case diagram


Insurance system

Create Sales Data <<include>>

Salesman Browse Catalog <<include>> Update Sales Data

<<extend>>
Stereotypes

Browse Holiday Special Catalog

23 Jun 2004

Wipro Confidential

18

Sequence diagram
Used for dynamic modeling of the system
Symbols/ Notation Class roles Actor Description The class role is a view of the class that helps achieve a particular functionality. The notation and use of actor is same as that described in the use case diagram. The actors start a sequence by acting upon the system. Represented the same way as the actors of the use case diagram.

Message
Lifeline

A message is ideally a method call between two classes.


Lifeline denotes the life span of a method call. Unless the method implementation is asynchronous, all the calls block till the child calls return. This diagram helps to see if any object is blocked unnecessarily during a call which can be avoided. These are self calls; when a object makes a call to itself to get some information.

Loops

23 Jun 2004

Wipro Confidential

19

Sequence diagram
Message
: OrderEntryClerk start() OrderEntryWindow prepare()

Class role
Order prepare() OrderLine checkLevel() isReorderLevel() Item

Loop Lifeline
reOrder()

if reorder level is reached

23 Jun 2004

Wipro Confidential

20

Collaboration Diagram
Used for dynamic modeling of the system
Symbols/ Notation Objects Links Message numbering Description The collaboration diagram uses an instance of a class and denotes its behavior. The links demonstrate the method calls between the classes. The messages flowing between the classes are numbered so as to demonstrate how the messages are sequenced.

23 Jun 2004

Wipro Confidential

21

Collaboration Diagram

2: prepare() 1: start OrderEntryWindow Oder

: OrderEntryClerk

3: prepare()

OrderLine

4: checkLevel() 6: reOrder()

Object

Message numbering
5: IsReorderLevel()

item

23 Jun 2004

Wipro Confidential

22

State machine Diagram


Also called statechart diagram. Used for dynamic modeling. This is used to demonstrate the transitions for the state machine such as invoices, Purchase orders
Symbols/ Notation State Description State is represented by rounded edged rectangle. This is used to demonstrate the states at which the state machine waits for events to take place to move to a Created different or same state.

A state may be a combination of states.


Event transition Represented by a line with arrow. An event that triggers a state machine to move from one state to the other.
Created

Initial state

Represented by a solid filled circle. Used for displaying the starting point of a state machine. Represented by a circle surrounding a solid filled circle. This marks the end of the state transition of the state machine. Here either the transaction is committed or rolled back. Transition that keeps the state machine where it was before the event transition.
Created

Final state

Self

23 Jun 2004

Wipro Confidential

23

State machine Diagram

Invoice Created

States
Unpaid Paid Paid Transaction Committed

Start State

End State

State transition

23 Jun 2004

Wipro Confidential

24

Activity Diagram
Used for modeling business requirements
Symbols/ Notation Activity Description This is represented by a rectangle whose vertical sides are represented as semicircles. Receive order This is used to represent activity as the name suggests. Represented by lines with arrowheads. These are used to show how the actions change the system behavior. Notation and usage are same as that of the Statechart diagram. Notation and usage are same as that of the Statechart diagram. Swim lanes are represented by vertical bars with titles that divide the activity diagrams into various sections. These are used to denote the processes used by Procurement div various groups in an organization

Action flow Initial state End state Swim lanes

Synchronization

This is represented by a horizontal or vertical bar. This is used to denote concurrent activities. Represented by a diamond and denotes a decision point. Notation and usage are same as that of the Statechart diagram. Denoted the same way as the states in the state chart diagram.
Wipro Confidential

Decision States

23 Jun 2004

25

Activity Diagram
Start

Receive Order Fork Activity

Fill Orders

Send Invoice

Send Invoice

Branch

Overnight Delivery

Regular Delivery

Receive Payment

Join Join Close orders

End

23 Jun 2004

Wipro Confidential

26

Component Diagram
Used for representing the implementation view of the system. Represents software view of the system
Symbols/ Notation Component Description Components are represented by the symbols described as
C1

It is used to denote independent piece of executable or code that can be used to achieve some functionality. Dependency This is denoted by a dotted line with arrowhead. The dependency can have a name associated with it. This is used to denote type of dependency between two components.

23 Jun 2004

Wipro Confidential

27

Component Diagram

Monitoring Component Uses Uses


Dependency

Violation Correlator Component

Logging component

Component

23 Jun 2004

Wipro Confidential

28

Deployment Diagram
Used for deployment view of the system. Represents hardware as well as software view of the system. This view is used by the system administrators and maintenance persons
Symbols/ Notation Node Description This is denoted by a three dimensional box. This denotes a physical hardware. The location and software installed on this can be denoted to make it more meaningful for the system administrators and maintenance people. Communication This is denoted by a text between << and >>. This is used to denote the type of communication between the nodes.

23 Jun 2004

Wipro Confidential

29

Deployment Diagram

<<TCP/IP>> Client PC <<HTTP>> Web Server Application Server <<RMI>> Database Server

Client PC

<<TCP/IP>>

23 Jun 2004

Wipro Confidential

30

UML Dos and Donts


Dos: Create models for the complex components in the beginning and attack the other components later. Keep the model modular to make them simple and clear; complex models are not effective. Check the accuracy of the model by using the tool or by expert review. Maintain the model consistency and integrity- different views of the same model should not tell a different story. Iterate through the model so that it evolves over a period of time to provide the right level of contents Keep the model updated- can reverse engineer the code to update the model at the end of the project. Donts: Dont mix UML with the project methodology; UML is generic enough to fit to any methodology. Dont try to create all the UML diagrams because they are defined; choose the ones that are best fit for the solution to be designed. Choose the right model depending on the audience; use case and activity diagrams are perfect for the business users whereas class diagram, collaboration diagram and sequence diagrams etc. are more useful for the designers.

23 Jun 2004

Wipro Confidential

31

UML Tools
Some of the advanced tools available in the market are: Rose (from IBM-Rational) Together Control Center (From Borland)

Select Enterprise (From Aonix)


Magic Draw (Magicdraw) OptimalJ (Compuware) Microsoft Visio (Microsoft)

Some of the major features supported by the tools vendor that makes the tool lucrative for usage are Repository based modeling Capability for code generation

Multi-user support
Reverse engineering (generating design model from the existing code) Interchange of tools (via data exchange through XMI xml metadata interchange) Integration with other tools (such as requirement management and testing tools)

23 Jun 2004

Wipro Confidential

32

Whats Next
To start using UML in a project you may do the following: Learn and practice UML Choose a tool Decide what diagrams are best suited for the project Decide whether to use a platform specific model (PSM) or platform independent model (PIM) Stat using it and get the models reviewed by the experts Some of the link that would help towards learning UML model is to http://www.omg.org/gettingstarted/what_is_uml.htm For definition of terms http://www.softdocwiz.com/UML.htm

23 Jun 2004

Wipro Confidential

33

References
UML distilled by Martin Fowler & Kendall Scott UML 2 toolkit by Hans-Erik Eriksson, Magnus Penkar, Brian Lyon, David Fado Tool: Rational rose for illustrations http://www.omg.org/gettingstarted/what_is_uml.htm#12DiagramTypes

23 Jun 2004

Wipro Confidential

34

Thank You

Our promise
With utmost respect to Human Values, we promise to serve our customers with Integrity, through Innovative, Value for Money solutions, by Applying Thought, day after day

23 Jun 2004

Wipro Confidential

35

Das könnte Ihnen auch gefallen