UML - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

UML

Description:

UML Dr. Zhen Jiang West Chester University E-mail: zjiang_at_wcupa.edu Association Class (relation attributes) Each object of association class is one instance of ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 46
Provided by: zji
Learn more at: https://www.cs.wcupa.edu
Category:

less

Transcript and Presenter's Notes

Title: UML


1
UML
  • Dr. Zhen Jiang
  • West Chester University
  • E-mail zjiang_at_wcupa.edu

2
Outline
  • Introduction to UML
  • Objects and Classes
  • Class Diagrams
  • Class Icon
  • Relationships
  • Constraints

3
UML Unified Modeling Language
  • The Unified Modeling Language (UML) is an
    industry-standard language for specifying,
    visualizing, constructing, and documenting the
    artifacts of software systems
  • The UML definition was led by Grady Booch, Ivar
    Jacobson, and Jim Rumbaugh (all now at Rational
    Software)

4
Objects and Classes
  • Whats object
  • Identity
  • State
  • Behavior
  • Sequence Diagram
  • Statechart Diagram
  • Messages and methods
  • Whats class
  • Objects and Classes
  • Nature of a class
  • Class Attributes
  • Operation (Method)
  • Interfaces
  • Interfaces and Implementation
  • Corresponding C code

5
Objects
  • Conceptually, there are many ways to think of an
    object
  • something that can be seen or touched
  • a thing to which some action is directed
  • something that performs a query action
  • The structure and behaviour of similar objects
    are defined in their common class
  • Objects have thee properties identity , state,
    and behaviour (query action)

6
Object Property 1 Identity
  • Identity is that property of an object which
    distinguishes it from all other objects
  • Keep in mind, however, that an object may not
    have a name Similarly, an object might have
    multiple names (aliases)
  • For this reason, there is a subtle distinction
    made between the concepts of "name" and "identity"

7
Object Property 2 State
  • The state of an object encompasses all of the
    (usually static) properties of the object plus
    the current (usually dynamic) values of each of
    these properties

8
Object Property 3 Behaviour
  • Behaviour is how an object acts and reacts, in
    terms of its status changes and
    message/information passing
  • The state of an object represents the cumulative
    results of its behaviour

9
Example Objects
  • There are many physical objects we can examine
    right in this room
  • each person is an object
  • any chair is not an object
  • each light bulb is an object
  • Any book is not an object
  • this room itself is an object (full or not)

10
  • See if the followings are objects or not
  • Desk
  • Light
  • Person
  • Log
  • The Earth
  • Clock
  • Machine
  • Computer
  • Saving account
  • Answer N, Y, Y, N, Y, Y, Y, Y, Y

11
Objects versus Classes
  • How would we describe the state, behaviour, and
    identity for each of these objects
  • We have looked at objects and we have seen that
    objects can be "classified" into classes
  • As programmers, we work with both classes and
    objects from those classes

12
Classes and Objects
  • An object is called an "instance" of a class
  • The terms instance and object are interchangeable
  • Creating an object from a class is often called
    instantiation
  • For example, there are many person objects in
    this room -- each person is an instance of the
    person class

13
The Nature of a Class
  • A class describes the common structure
    (attributes/state) and behaviour of its instances
  • For example,
  • 3.14, 2.71, and 5.5 can be classified as Floats
  • the following shapes can be classified as Circles

14
  • In a 2D drawing package, circles have a radius, a
    line thickness, a line color, and a fill color
  • Each individual circle (instance) drawn by the
    user has its own value for each attribute
  • The programmer writes a Circle class and the
    program instantiates a Circle object every time
    the user draws a Circle

a snowman made from 9 Circle instances
15
Class Attributes
  • An attribute is a named property of a class that
    describes the range of values that instances of
    the property may hold.(Booch,1999)
  • An attribute has a type that defines the type of
    its instances.
  • Only the object itself should be able to change
    the value of its attributes.
  • The values of the attributes define the state of
    the object

16
Operation (Methods)
  • An operation is the implementation of a service
    that can be requested from any object of the
    class to affect behavior (Booch, 1999)
  • An operation can be
  • Question (does not change the value of the
    object)
  • Command (may change the value of the object)

17
Review
something
Object
action
action
state1
state2
operations/methods
attributes attribute1,
attribute2
structure
operation/method
attribute1
attribute2
value
18
Light
Turn on/off
On
Off
operations/methods
Turn_on/off ( )
attributes True, False
structure
Turn_on
True
False
value
Turn_off
19
Class Diagram
  • Introduction
  • Class Icon
  • Relationships
  • Constraints

20
Introduction
  • The class diagram is fundamental to
    object-oriented programming
  • UMLs class diagrams capture the attributes and
    operations of each class as well the
    relationships that exist between classes

21
Class Icon
  • Class Icon
  • Hiding Details
  • Visibility Notation
  • Attribute Specification
  • Operation Specification

22
UML Class Icon
  • The UML class icon is a rectangle with three
    compartments
  • class name
  • class attributes
  • class operations
  • Attributes are specified in the following form
  • objectclass name

Circle
radius float center_x int center_y int
area() display()
23
Hiding Detail
  • You can optionally leave out the attributes,
    operations, or both in a class icon

Circle

area() display()
Circle
radius float center_x int center_y int
Circle
24
UML Member Visibility Notation
  • UML has three visibility prefixes for members
    for public, for protected, and for private
  • e.g.

Circle
-radius float
area() display()
25
Full UML Attribute Specification
  • The full form of a UML attribute is as
    followsvisibility name multiplicity
    type initial value property
  • The property choices are changeable, addOnly, and
    frozen

Student Info
-id string -hasGraduated bool false
26
Full UML Operation Specification
  • The full form of a UML operation is as
    followsvisibility name (parameter-list)
    return-type property
  • The property choices are sequential, concurrent,
    guarded, and isQuery
  • The full form of a UML parameter isdirection
    name type default-value
  • The direction choices are in, out, and inout

27
UML Class Relationships
  • A class relationship is a connection between two
    (or more) classes
  • The three most important class relationships are
    generalizations, associations, and aggregations
  • UML provides a graphical representation for each
    of the relationships using a different line type
    for each relationship

28
Class Relationships
  • Generalization
  • Association
  • Association Class
  • Qualified Association
  • Ternary Association
  • Aggregation

29
Generalization
  • A generalization is a relationship between a
    general thing (superclass) and a more specific
    kind of that thing (subclass)
  • In the UML, generalization requires that objects
    of the subclass may be used anywhere an object of
    the superclass appears

Person
Student
30
Association
  • An association is a structural relationship that
    specifies that objects of one thing are connected
    to objects of another

Faculty
Student
31
Association
  • Associations can be adorned with a name.

Teaching
Faculty
Student
32
Association
  • Associations can be adorned with the roles.

teacher
Faculty
Student
learner
33
Association
  • Associations can be adorned with the
    multiplicity.

Faculty
Student
4..
1
34
Association Class (relation attributes)
  • Each object of association class is one instance
    of relationship (link) in an association.

1..
Faculty
Student
4..
Course
35
Qualified Association
  • Qualified association relates two classes and a
    qualifier.
  • The qualifier is a special attribute that reduces
    the effective multiplicity of an association.

Directory
File
file name
36
Ternary Association
  • A ternary association is a structural
    relationship that specifies that objects of one
    thing are connected to objects of other twos.

Language
Project
Developer
37
Aggregation
  • An aggregation is an association that represents
    whole/part relationship
  • The whole end of the association relationship
    is adorned with an open diamond shape (e.g. X is
    part of Y)
  • e.g. doorDoor is part of carCar

X
Y
38
Generalization, Aggregation, and Association
  • See if the following pairs of classes have
    generalization, aggregation or association
  • Faculty student (as)
  • Hospital doctor (as)
  • Door Car (ag --ltgt)
  • Member Organization (ag --ltgt)
  • People student (ge lt-- )
  • Circle point (ge --gt)
  • Department Faculty (as)
  • Employee Faculty (ge lt--)
  • Item Printer (ge lt--)
  • Account Checking account (ge lt-- )

39
Constraints
  • Constraints on Object
  • Constraints on Relations (Ordering)
  • General Constraints (Dependency)

40
Constraints on Object
  • The constraints restricts the values that objects
    can be.
  • Example No employees salary can exceed the
    salary of the employees boss.

salary ltboss.salary
Employee Salary
Employer Salary
41
Constraints on Relations (Ordering)
  • Order indicates that the elements of the many
    end of an association have an explicit order that
    must be preserved.

ordered
Paper
Author
1
1..
42
General Constraints (Dependency)
  • A dependency is a using relationship that states
    that a change in specification of one thing may
    affect another thing that uses it (but not
    necessarily the reverse)

43
General Constraints (Dependency)
  • Dependencies are often used when one class uses
    another class as an argument of the operation
  • Dependencies are also often used to express
    general constraints.

Aerodrome
checkRVR( r Runway )
Runway
member-of
Person
Committee
subset
chair-of
44
  • (Class Name, attribute, method) vs (Table Name,
    field, query)
  • (Class object) vs (Table row)
  • (Table 1, table 2, ) vs Knowledge relearning
    with OO techniques to quickly locate the
    information

45
Design
  • Organize the data into something (i.e.,
    object) being queried.
  • Observe the relationship between objects.
  • Describe the queries into methods, changing,
    updating, and even deleting the attribute
    information.
  • If necessary, translate class, object, attribute
    value, and method to table, row, field value, and
    query.
Write a Comment
User Comments (0)
About PowerShow.com