Sei sulla pagina 1di 52

Your key to Object Orientation !!!

Dhwanit Shah IIIT-Bangalore

Unified Modeling Language (UML) is a standardized general-purpose modeling language in the field of object oriented software engineering. The standard is managed, and was created by, the Object Management Group.

Not only set of diagrams !!! UML Model = Diagrams + Documentation

Documentation =

Info. Of Diagrams Written Usecases Interaction Stories Flow Of Events Screen Navigations

A diagram is typically a view of a part of the model, showing modeling elements and some of the relationships between them. A diagram do not have to be complete, some elements may be missing or presented in a simplified fashion.

Totally there are 14 different diagrams. They are classified under two categories:
Structure diagrams Behavior diagrams

Structure diagrams are used to represent the structure (components, their interactions etc.) of the system being modeled. Behavior diagrams describe what must happen in the system being modeled.

Logical

Component

Use Case

Deployment

Concurrency

How the functionality is designed inside the system, in terms of the systems static structure and dynamic behavior Key mechanisms of the system are identified (like implementation language, look and feel of UI, Error Handling etc) Classes, Relationships, Class diagrams

Organization of the code components. Packages, Components and Component diagrams

Addresses the problems with communication and synchronization that are present in a concurrent system Sequence diagrams and Collaboration diagrams

Deployment of the system into the physical architecture with computers and devices called nodes. Deployment diagram

The functionality of the system as perceived by external users called actors. Focuses on usability of the system. Use-case Diagram

UseCase Diagram in Rose

To depict the classes within a model Express in a general way, the static structure of a system, in terms of classes, interfaces and relationships between those classes. The fundamental element of the class diagram is an icon that represents a class.

A class icon is a rectangle divided into three compartments. Attributes are the information stored about an object (or at least information temporarily maintained about an object), while operations are the things an object or class do.

Class

Attribute(s)
Operation(s)

Class name
Attribute name : type = initial value {+,#,-}operation() + corresponds to public # corresponds to protected -corresponds to private underline corresponds to static

italic corresponds to abstract

Account -Name #Type : string = SA +OpenAccount(in Type : string) : bool{exceptions=DatabaseError} #ValidateAccount() : bool

interface IAccount +OpenAccount(in Type : string)


IAccount

An interface can be represented as a class like icon or a lollipop icon Interfaces names are based on the language naming conventions

A group of classes of related classes can be grouped under a package to share values and functionality. A package can be used to help reduce complexity of the model. Packages can be nested or imported.

Accounts

Associations
is a connection between classes, which means it is a

connection between objects of those classes modeled as lines connecting the two classes whose instances (objects) are involved in the relationship.
Class A

multiplicity A role A

label

multiplicity B role B

Class B

Association
represents the ability of one instance to send a

message to another instance a filled triangle, called direction indicator is used to depict the direction in which label is read
Man -boyfriend -girlfriend Woman 1 1

Student -Name -PhoneNo +Create()

lives at -my address 1 1..*

Address -StreetNo -City +Validate()

Association Java Implementation [Example:] |Student|----------->|Address| Class Student { private Address address; } Class Address { }

Association
Cardinality/Multiplicity
Symbol 0..1 1 0..* 1..* n 0..n 1..n Meaning Zero or one One only Zero or more One or more Only n (where n > 1) Zero to n (where n > 1) One to n (where n > 1)

Dependency
is a unidirectional use relationship.
used when the relationship is short term is a relationship between elements, one independent and

one dependent a change in the independent element will affect a change in the dependent element represented using dashed line with direction indicator
Document call SpellChecker

Aggregation
indicates a whole-part relationship between

classes key words like consists of, contains, part of is represented by adding a small empty diamond next to the aggregate
Order 1 -shipping address Address

Class Order { private Address shippingaddr; public AddAddress(Address adr) { //Implementation goes here } }

Composition
stronger whole-part relationship
parts are physically contained in the aggregate destroyed along with the whole is represented by adding a small filled diamond

next to the aggregate


Order 1 -items OrderItem

0..*

Generalization
is a relationship between a more general and a

more specific element (Inheritance) models is a and is like relationships is represented by adding an empty triangle next to the super class
IAccount

Account -Name #Type : string = SA +OpenAccount(in Type : string) : bool{exceptions=DatabaseError} #ValidateAccount() : bool

Recursive Association

Node * *

-wife

Person

* married to * -husband

Association Class
is a special type of class that defines a relationship

between two other classes often occur in many-to-many associations where the association itself has attributes rendered by a dashed line from the association to the class rectangle
Woman 1 1 Man

-wife

-husband

Marriage

Parameterized Class
represents a generic type
T Stack

public class Stack<T> { T[] m_Items; public void Push(T item) {...} public T Pop() {...} } Stack<int> stack = new Stack<int>(); stack.Push(1); stack.Push(2); int number = stack.Pop();

Catalog

Address

1 0..* -items holds 0..1 1 Shopping Cart checks out to 1

-address

* 1

StockItem

Order 1 call

-items

OrderItem

0..*

TaxCalculator

A use case is a specific way of using the system by performing some part of the functionality. Each use case constitutes a complete course of events initiated by an actor, and it specifies the interaction that takes place between an actor and the system.

Includes: - Parent use case make use of the functionalities provided by the child use case thereby including it as follows:
<<includes>>

Parent

Child

Extends: - Child extends/adds additional features to the generic use case. But it extends only some functionalities of the parent use case
<<extends>>

Child

Parent

Uses: - The entire parent use case is being used by the child use case. All the functionalities of parent use case are being used by child use case.
<<uses>>

Child

Parent

Grouping: - use cases handling similar/related functionalities can be grouped together into a single UML package.

Accounts

To model the flow of logic (sequential logic) within the system in a visual manner. Focuses on identifying the behavior within the system. Considering Timing Factor.

cartPage : CartPage Customer Add To Cart CreateCart()

cart : Shopping Cart

checkOutPage : CheckOutPage Printer

AddToCart() {Loop}

order Check Out CheckOut() Create Order Load(Order)

Print Print

The boxes across the top of the diagram represent classifiers or their instances The dashed lines hanging from the boxes are called object lifelines, representing the life span of the object The long, thin boxes on the lifelines are activation boxes, which indicate processing is being performed by the target object/class to fulfill a message

To show the behavior of several objects collaborating together to fulfill a common purpose. Show the message flow between objects and also imply the basic associations (relationships) between classes. Considering Space(Links) Factor.

Add To Cart Check Out cartPage

CreateCart() AddToCart() CheckOut() cart

Load(Order)

customer

checkoutPage order

Create

Pr in

The rectangles represent the various objects involved that make up the application. The lines between the classes represent the relationships (associations, composition, dependencies, or inheritance) between them. Messages are depicted as a labeled arrow that indicates the direction of the message. Method representation(optional):
concurrency letter sequenceNumber loopIndicator : returnValue := methodName(parameters)

An arrow for each message Concurrent threads are indicated with letters Links should be consistent static relationships

Used to describe the functional behavior of the system. Have states, transitions, events and/or actions.
States store information regarding the current

status of the program. Transitions are triggered by events and depict change of state on occurrence of actions. Transitions can have guards indicating conditions on when they can happen.

States can have lot of structure:


They can be hierarchical, with sub-states. They can have orthogonal components. Can also have values of variables explicitly

mentioned as a part of their description.

Questions ???

Thank You

Potrebbero piacerti anche