UML (Unified Modeling Language) - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

UML (Unified Modeling Language)

Description:

UML (Unified Modeling Language) Sources: 1. UML Toolkit. Eriksson, Hans-Erik; Penker, Magnus. John Wiley & Sons, INC. 1998. 2. Program Development in Java. – PowerPoint PPT presentation

Number of Views:87
Avg rating:3.0/5.0
Slides: 51
Provided by: defau1452
Category:

less

Transcript and Presenter's Notes

Title: UML (Unified Modeling Language)


1
UML (Unified Modeling Language)
Sources1. UML Toolkit. Eriksson, Hans-Erik
Penker, Magnus. John Wiley Sons, INC.
1998.2. Program Development in Java. Liskov,
Barbara Guttag, John. Addison-Wesley. 2001.
2
UML Tools
  • http//www.objectsbydesign.com/tools/umltools_byCo
    mpany.html is a good source of tools available
  • TJHSST has Dia, which will be utilized.

3
Software Life Cycle
  • Requirements
  • Architecture Design
  • Detailed Design
  • Implementation (Coding)
  • Testing
  • Deployment
  • Maintenance

UML is concerned with these two phases.
4
The Class Diagram
  • Drawn with a rectangle, divided into 3
    compartments
  • Name compartment
  • Attribute compartment (Instance variables)
  • Operations compartment (Methods)

5
Class Diagram Example
  • Consider a Polynomial class (Poly)
  • Form a1x0a2x12 . Anxn-1n
  • Key attributes terms and degree
  • Instance Variables - means private variable
    means public variable
  • Underlined instance variables static.

6
Poly using Dia
7
Poly methods
  • Common things done to polynomials
  • return degree
  • return coefficient of corresponding exponent
  • Subtract two polynomials
  • Add two polynomials
  • Multiply two polynomials
  • Take the negative of a polynomial

8
Poly Class Diagram
Basic syntax visibility name (parameter-list)
return-type-expression property string
degree() int coeff (d int) int sub
(thePoly Poly) Poly minus () Poly add
(thePoly Poly) Poly mul (thePoly Poly) Poly
9
Poly Implementation
  • public class Poly
  • private int trms
  • private int deg
  • public Poly ()
  • // constructor goes here
  • public int degree
  • public int coeff (int d)
  • public Poly sub (Poly thePoly)
  • public Poly minus (Poly thePoly)
  • public Poly add (Poly thePoly)
  • public Poly mul (Poly thePoly)

10
Class Diagram Relationships
  • Association
  • Generalization
  • Dependency
  • Refinement

11
Class Diagram Relationships
  • Association
  • Generalization
  • Dependency
  • Refinement

12
Associations
  • A connection between classes.
  • Usually classes know about each other
    (bidirectional.)
  • Name of association necessary (Uses in below
    case.)

Specifically, an author uses a computer hence,
Author has an association with Computer.
13
More Normal Associations
  • A person owns 0-many cars. A car is owned by 1
    to many people.
  • If relationships are not specified, then it
    assumed to be 1-1.
  • Relationships can begin and end with any number
    . i.e. can have 5..11 or 19..25.
  • Relationships can be a multiple list
    (1,4,6,8..12)

14
Another Normal Association Example
Insurance Policy
0..1
Expresses an
Is expressed in an
1
1
has
0..
Insurance Contract
Insurance Company
Refers to
0..
Refers to
has
1..
Customer
15
Object Diagram
  • A class diagram, but with a specific
    instantiation

Use
0..
1..
Bob Author
Bobs PC Computer
Object Diagram
name Bob J age 32
name Dell 466 mem 64
16
Recursive Association
  • Class that calls itself.
  • Example Network Nodes (Class Diagram)


Node

Connects
17
Node Object Diagram
Node2
Node3
Node1
Node4
Node5
Node7
Node8
Node6
18
Roles in Association
  • An association can have roles connected to each
    class involved in the association.

drives


Car
Person
Company car
driver
19
Qualified Association
  • Used with one-to-many or many-to-many
    associations.
  • Qualifier distinguishes among the set of objects
    at the many end of an association.

Describes a unique identification for each figure
(figure id)
20
Or Association
  • Occurs when all combinations in a model are not
    valid.
  • Example
  • A person can have an insurance contract with an
    insurance company
  • A company can have an insurance contract with an
    insurance company
  • A person and a company CANNOT have the same
    insurance contract with an insurance company.

21
Or Association Diagram
1
0..
Insurance Contract
Insurance Company
0..
0..
or
1..
1..
Person
Company
22
Ordered Association
  • Links may have an implicit order.
  • Associations are unordered by default.

Standardized Insurance Contract
0..
ordered
1..
Customer
23
Association Class
  • A class is attached to an association.
  • Not connected at any of the ends of the
    associations.
  • Has attributes and operations also.

24
Association Class
  • Association Queue class.

Queue
Queue
4
Elevator Control
Elevator
Elevator Control

Button
Button
25
Ternary Association
  • More than 2 classes can are associated with each
    other.
  • Shown with a large diamond.

1
0..
Insurance Contract
Insurance Company
insurer
0..
0.. 1
Insurance Policy
policyholder
1..
Person
26
Aggregation
  • Special case of association
  • Relationship between classes is some sort of
    whole-part.
  • Example A CAR consists of 4 wheels, engine,
    chassis, gear box, etc.
  • Shown as a line with a hollow diamond on the end
    of it.

27
Aggregation Example

Warship
Navy
Contains
Excerpt from UML Toolkit The navy contains
warships. Warships can be added or removed, but
you still have a Navy. The hollow diamond shows
aggregation.
28
Shared Aggregation
  • The parts may be parts in any wholes



Person
Team
Members
A team has members. A person may be a member of
many teams.
ordered


Sound Clips
Remix
Contains
A remix has many sound clips the same soundtrack
could be a part of many remixes.
29
Composition Aggregation
  • An aggregation that owns it parts.
  • I.E. Strong ownership.

The window contains (is aggregated of) many
menus, button, listboxes, and texts.

Text
Window

Listbox

Button
Menu

30
Composite Aggregation

Text

Listbox
Contains
Window

Button
Menu

A different view of the same diagram on the
previous slide.
31
Composition Aggregation (Yet Another View)
Window

Text

Listbox

Button

Menu
32
Class Diagram Relationships
  • Association
  • Generalization
  • Dependency
  • Refinement

33
Generalization
  • Definition in UML A taxonomic (taxonomy is the
    science of classification) relationship between a
    more general element and a more specific element.
  • More specific element is fully consistent with
    more general element
  • More specific element contains more information.
  • Also known as Inheritance.
  • Is-a relationship.

34
Normal Generalization
  • Subclass inherits everything from superclass.
  • Attributes, operations, and all associations are
    inherited.
  • Private members will be inherited, but not
    visible to the subclass.
  • Protected members accessible only by subclass.

35
Class Hierarchy Diagram
Vehicle
Car
Truck
Boat
36
Another Class Hierarchy Diagram
Vehicle
Car
Truck
Boat
37
Abstract Classes
  • Not allowed to have objects.
  • Used only for inheritance
  • Described common attributes and behavior for
    other classes.

38
Abstract Class Hierarchy Diagram
Vehicle abstract
drives

Person
color
drive () abstract
Car
Boat
drive ()
drive ()
39
Another Abstract Class Hierarchy Diagram
Figure abstract

Figures
position Pos
draw () abstract
Group
Polygon
draw ()
draw ()
40
Java Implementation
  • Abstract public class Figure
  • abstract public void draw()
  • protected Pos position
  • public class Group extends Figure
  • public void draw ()
  • for (int i 0 i lt
    consist_of.size() i)
  • consist_ofi.draw()
  • private FigureVector figures /
    FigureVector is a specialized class of the
    standard Vector class that implements a dynamic
    array. FigureVector adds hard type checking /

41
Java Implementation (cont)
  • public class Polygon extends Figure
  • public void draw ()
  • // draw polygon code

42
Overlapping and Disjoint Generalizations
  • Overlapping Further subclasses inheriting from
    the subclasses in the inheritance relationship
    can inherit more than one of the subclasses (This
    is not supported in Java basically multiple
    inheritance.)
  • Disjoint Subclass are not allowed to be
    specialized into a common subclass.
  • Is the default

43
Complete and Incomplete Generalization
  • Complete All subclasses have been specified
    (i.e. Final in Java)
  • Incomplete Subclasses may be added later on.
  • Generally the norm
  • The default

44
Example Complete Generalization
Person
complete
Man
Women
45
Class Diagram Relationships
  • Association
  • Generalization
  • Dependency
  • Refinement

46
Dependency Relationship
  • Semantic connection between 2 model elements
    one independent and one dependent
  • Changes in the independent element will affect
    the dependent.
  • Examples
  • One class takes an object of another class
    (Composition)
  • One class accesses a global object of another
    class
  • One class calls a class-scope operation in
    another class.

47
Example Dependency Diagram
ltlt friend gtgt
Class A
Class B
  • The dependency is shown as a dashed line with an
    arrow
  • The type of dependency is called a stereotype
    in this case, it is a friend dependency

48
Refinement
  • Relationship between two descriptions of the same
    thing, but at different levels of abstraction.
  • Can be between a type and class that realizes it
  • Called a realization

Analysis class
Design class
Shown with a dashed line and a hollow triangle
49
Interfaces
  • Described as abstract operations.
  • In Java the way to sneak around the inability
    for multiple inheritance.
  • Shown as a small circle with a name.
  • Connected to its model element via a solid line.
  • A class that uses the interface as implemented in
    a specific class is connected via a dependency
    relationship to the interface circle.

50
Interface Diagram Example
Storable
Class A
Class B
Runnable
ltltinterfacegtgt Runnable abstract
ltltinterfacegtgt Storable abstract
Class C
Runnable
run() abstract
load() abstract save() abstract
Class A implements the interfaces Runnable and
Storable. Class C implements the interface
Runnable. Class B uses the interface Runnable
and Storable from A, and Runnable from C. The
interfaces are specified as classes with the
stereotype ltltinterfacegtgt and contain the abstract
operations that the implementing classes must
implement.
Write a Comment
User Comments (0)
About PowerShow.com