chapter 6 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Unified Modeling Language (UML) PowerPoint Presentation
Download Presentation
Unified Modeling Language (UML)

Loading in 2 Seconds...

play fullscreen
1 / 31

Unified Modeling Language (UML) - PowerPoint PPT Presentation


  • 195 Views
  • Uploaded on

(Chapter 6). Unified Modeling Language (UML). Unified Modeling Language. UML October 1994 Three Amigos Grady Booch (Rational Software) [Booch] James Rumbaugh (Objectory) [OMT] Ivar Jacobson (General Electric) [OOSE]

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Unified Modeling Language (UML)' - abbott


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
unified modeling language
Unified Modeling Language
  • UML October 1994
  • Three Amigos
    • Grady Booch (Rational Software) [Booch]
    • James Rumbaugh (Objectory) [OMT]
    • Ivar Jacobson (General Electric) [OOSE]
  • Modeling language = mainly graphical notation that a modeling process uses to express designs
why model
Why Model?
  • Simplification of reality
  • Better understand a complex system
    • visualization of the system
    • specification of structure or behavior of the system
    • implementational template
    • documentation
  • Facilitate finding the "best" solution
  • Communication tool
uml is a
UML is a:
  • Language for visualization
    • graphical representation (static and dynamic)
  • Language for specifying
    • precise, unambiguous, and complete
  • Language for constructing
    • mapping from UML to OO programming language
  • Language for documenting
    • requirements, architecture, design, source code, plans, testing, prototypes, releases
static models in the uml class diagrams
Static Models in the UML(Class Diagrams)
  • Purpose
    • To depict classes and their attributes (data members), operations (methods) and relationships to other classes
  • Primary diagram structure
    • Class icon: rectangle divided into three compartments
        • Name, attributes, operations
    • Various types of connecting lines depict various types of relationships with other classes
classname attribute type operation returntype
ClassName

Attribute : Type

Operation() : returnType

The Class Icon
example simplest class diagram
Example: Simplest Class Diagram

An Attribute is followed by a

colon and its type

An Operation is followed by a

colon and its return type

Parameters are types only or

name : type

Circle

radius : double

center : Point

setCenter(Point)

setRadius(double)

area() : double

circumference() : double

This typing convention is used to create separation between the design and an implementational language.

relationships between classes
Relationships between Classes
  • Where the power in a static diagram resides
  • Association - an object of one class is connected to objects of another class
    • Class roles
    • Aggregation - a "whole" object of one class is made up of "parts," which are other objects
    • Composition - stronger form of aggregation
relationships between classes cont
Relationships between Classes (cont)
  • Generalization - an object of one class is a kind of object of another class
    • Inheritance
  • Dependency - an object of one class uses the services of (and therefore depends on) another object of a different class
association
Association
  • Represents a relationship between instances of two classes
  • Each association has two association ends, attached to one of the classes in the association
  • An end can be explicitly named with a label, or role name.

Class A

Class B

role B

role A

roles
Roles
  • A role name becomes a data field name in the associated class definition
    • For example, role B becomes a data field name in the definition of class A
  • In the absence of a role name, the association end name is derived from the class attached to that end
association and navigability
Association and Navigability
  • An arrowhead on an association end indicates navigability; the target class is known about by the other class
  • Lack of arrowheads on an association indicates that the relationship is bidirectional
  • Additional notations indicate multiplicities
multiplicities
Multiplicities

Class

1

exactly one

Class

*

many (zero or more)

Class

0..1

optional (zero or one)

Class

m..n

numerically specified

example of associational relationship
Example of Associational Relationship

Game

Board

1

0..1

state : long integer

playAgain : bool

board

promptPlayAgain():bool

newBoard() : Board

update(Move)

display()

This diagram depicts one Game being associated with zero or one Boards. The arrowhead creates a directional relationship, meaning the Game knows about the Board, but not vice versa. The name on the arrow is called a role. The numbers are called multiplicities.

classes can be self associated
Classes can be Self-Associated

Linked_List

1

next

data : someType

setData(someType)

getData() : someType

1

The members of a linked-list may have differing lifetimes and their children may change. Therefore, the nodes of a linked-list have relatively weak relationships.

composition a strong relationship
Composition: A Strong Relationship
  • ``Has-a'' relationship
  • When one class of object is composed of at least one instance of another class, we say that class "is made of" or "is composed of" (at least partially) the second class
  • An object can be part of only one other object
  • The multiplicity of the composing object is always 1
composition and lifetimes
Composition and Lifetimes
  • The composition relationship implies that the life span of the second class is coincident with that of the first class:
    • The constructor and destructor of the second class are called in constructor and destructor of the first class
diagram of compositional relationship
Diagram of Compositional Relationship

Circle

Point

1

1

center

x : double

y : double

radius : double

center : Point

setCenter(Point)

setRadius(double)

area() : double

circumference():double

setX(double)

setY(double)

getX() : double

getY() : double

The blackened diamond represents composition. The arrowhead

implies that the Point does not know about the Circle. The role

relationship is to provide a center point for Circle objects.

Note the unnecessary redundancy in the Circle attribute box, and

the unnecessary multiplicity on the diamond.

more on composition
More on Composition
  • Arrowheads restrict the directionality of relationships, like in all classes of associations
  • If the arrowhead had been missing in the last diagram, the implementational implication would have been that

#include "circle.H"

is within

point.H

so arrowheads tend to be the norm

implementation of composition

class Point{

public:

void setX(double);

void setY(double);

double getX(void) const;

double getY(void) const;

private:

double x;

double y;

};

Notice that Point knows nothing about Circles

Implementation of Composition
implementation of composition cont d

class Circle{

public:

void setCenter(const Point&);

void setRadius(const double);

double area(void) const;

double circumference(void) const;

private:

double radius;

Point center;

};

Here it is obvious that the Point data member lives and dies with the Circle. The Point could be implemented using a pointer, in which case it would have to be deleted in the Circle destructor.

Implementation of Composition (cont'd)
another composition example
Another Composition Example

Square

1

uLeft

2

Point

lRight

setCorners(Point,Point)

area() : double

class Square{

public:

void setCorners(const Point&, const Point&);

double area(void) const;

private:

Point uLeft;

Point lRight;

};

aggregation
Aggregation
  • Indicated with a non-blackened diamond
  • Weaker than composition regarding object lifetimes
  • Can be represented simply through multiplicities
aggregation example
Aggregation Example

lChild

BinaryTree

0..2

rChild

leftChild() : BinaryTree

rightChild() : BinaryTree

1

A binary tree would not be a tree, if it were not for its containing (aggregating) two of its own type. A node may contain zero to two children.

example structural relationship diagram
Example Structural Relationship Diagram

0..1

School

Department

1..*

1

1..*

1..*

1..*

0..1

chairperson

*

1..*

1..*

Student

Course

Instructor

*

*

*

1..*

generalization diagrams
Generalization Diagrams
  • Shows the "is-a" relationship between a general class of objects (superclass or parent) and their specializations (subclass, child or derived class)
  • Implies the child objects can be used in place of a parent, but not vice versa
  • Inherited attributes and/or operations are not repeated in the subclasses, unless they are polymorphic (virtual)
generalization diagrams cont d
Generalization Diagrams (cont'd)
  • Abstract classes have names
    • Italic font
    • {Abstract} label next to name
  • Virtual operations
    • Italic font
    • Can also be labeled with {Abstract}
example generalization diagram
Example Generalization Diagram

Queue

Item

1

maxSize: Integer

front: Integer

rear: Integer

*

items

display(): void

add(Item): void

remove(): Item

empty(): Boolean

full(): Boolean

FrontQueue

FrontQueue

example multiple inheritance diagram
Example Multiple Inheritance Diagram

InterestBearing

Insurable

Asset

Bank Account

Real Estate

Security

Checking

Savings

Stock

Bond

dependency
Dependency
  • Represents a "using" relationship
  • Implies a change in an object of one class may effect an object in another class which uses that object
    • The reverse is not necessarily true
  • The object depended on is not contained in the depending class object
  • Usually implemented as member function arguments
dependency diagram
Dependency Diagram

Board

Move

state : Integer

dir : Direction

updateBoard(m : Move)

nextMove() : Move

or

Board

Move

state : Integer

dir : Direction

updateBoard()

nextMove() : Move