UML Classes Sipping from the Fire Hose - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

UML Classes Sipping from the Fire Hose

Description:

UML Classes Sipping from the Fire Hose – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 25
Provided by: harold98
Category:
Tags: uml | breeds | classes | dogs | fire | hose | list | of | sipping

less

Transcript and Presenter's Notes

Title: UML Classes Sipping from the Fire Hose


1
UML ClassesSipping from the Fire Hose
  • November 14, 2007

2
Quiz
  • Draw a fully expanded class icon and identify
    which compartment holds what information

3
Session Goals
  • Understand and be comfortable with the following
    UML notations
  • UML Class
  • Various UML Associations

4
UML Class Diagrams
  • In software design, the most common diagram is
    the class diagram
  • Class diagrams depict classes in a software
    system and the relationships between the classes

5
Forms of the UML Class Notation
Fully Elided
Fully Expanded
ClassName
ClassName
ltattributesgt
ltoperationsgt
Partially Elided (operations only)
Partially Elided (attributes only)
ClassName
ClassName
ltattributesgt
ltoperationsgt
6
Visibility and Static notations
Visibility Notations Public ltnamegt Private -
ltnamegt Protected ltnamegt
Public, private, and protected have the usual
interpretations.
Static Underline ltnamegt
Static has the usual interpretation. Also
referred to as class-scope.
7
Attributes
  • Attributes represents characteristics of a class
  • Sometimes referred to as the class state data
  • Attributes can be specified in several forms

Generic Form for an Attribute
stereotypevisibility name type initial
value
8
Attribute Examples
No information about type No information about
default value Attribute is not static (has
instance scope) Unspecified visibility (often
assumed private)
name
No information about type No information about
default value Attribute is not static (has
instance scope) Attribute is protected
name
Is an instance or reference to an instance of
the class, String (language dependent) No
information about default value Attribute is not
static (has instance scope) Attribute is protected
name String
9
Attribute Examples
No information about type No information about
default value Attribute is static (has class
scope) Attribute is private
- count
Is an instance of int Has initial value of
0 Attribute is static (has class scope) Attribute
is public
count int 0
Example of a constant attribute (uses the frozen
constraint)
name String Fred frozen
10
Operations
  • Operations represent processes that a class knows
    how to execute
  • Operations, like attributes, have several
    variations on how the can be specified

Generic Form for an Operation
stereotype visibility static name
(parameter list) return type
Parameter List is defined as direction name
type default value
Direction is either in, out, or inout. When
unspecified, it is assumed to be in.
11
Operation Examples
No information about return type No information
about parameters Operation is not static (has
instance scope) Visibility unspecified (often
assumed public)
getCount()
Returns an instance of int No information about
parameters Operation has instance scope Operation
is public
getCount() int
Fully specified Operation
updateName (in to String) Status
12
Operation Examples
13
Class Examples Elided vs. Expanded
Fully Elided
BillardBall
Fully Expanded
BillardBall
_position Position _direction float
_energy float
init(in atPosition Position) void hitBy (in
ball BillardBall) void currentPosition()
Position
14
Class Example - Sale
C
UML - Fully expanded
class Sale protected bool _isComplete
Date _date Time _time ItemList
_items public Sale() Date date()
Time time() bool isComplete() void
addItem (Item item)
Sale
_isComplete bool _date Date
_time Time _items ItemList
Sale() date() Date time()
Time isComplete() bool addItem() void
15
Class Example - Sale
C
UML - Fully Elided
class Sale protected bool _isComplete
Date _date Time _time ItemList
_items public Sale() Date date()
Time time() bool isComplete() void
addItem (Item item)
Sale
UML - Partially Elided
Sale
Sale() date() Date time()
Time isComplete() bool addItem() void
16
Class Example - Dog
Java
UML - Fully expanded
public class Dog protected Breed _breed
protected int _ageInYears protected Name
_name protected boolean _isFixed
protected boolean _isHungry protected boolean
_isAsleep protected boolean _isBarking
public boolean isHungry() ... public
boolean isAsleep() ... public void eat()
... public void speak() ... public
void hush() ...
Dog
_breed Breed _ageInYears int _name
Name _isFixed boolean _isHungry
boolean _isAsleep boolean _isBarking
boolean
isHungry() boolean isAsleep() boolean eat()
void speak() void hush() void
17
Class Example Dog
Java
UML - Fully Elided
public class Dog protected Breed _breed
protected int _ageInYears protected Name
_name protected boolean _isFixed
protected boolean _isHungry protected boolean
_isAsleep protected boolean _isBarking
public boolean isHungry() ... public
boolean isAsleep() ... public void eat()
... public void speak() ... public
void hush() ...
Dog
UML - Partially Elided
Dog
isHungry() boolean isAsleep() boolean eat()
void speak() void hush() void
18
Exercise
  • Moving forward, we may encounter a potential
    problem with this representation of the class Dog
  • What might the problem be?

UML Representation Of Dog
Dog
breed Breed ageInYears int name
Name isFixed boolean isHungry
boolean isAsleep boolean
Dog() isHungry() boolean isAsleep()
boolean eat() void speak()
void hush() void
19
Perspectives
  • UML diagrams can communicate varying levels of
    information
  • Different levels serve different purposes
  • Class diagrams represent the entities within a
    system and their relationships
  • There are three perspectives common to class
    diagrams
  • Conceptual
  • Specification
  • Implementation

Note The names of the perspectives are not part
of UML and vary widely. We use them here mostly
for example.
20
Class Diagrams Conceptual Perspective
  • The conceptual perspective is used to communicate
    a very coarse structure of the system
  • Generally contains classes using a fully elided
    notation
  • This perspective is often as independent of any
    technology as possible
  • The classes could be implemented in any language

21
Class Diagrams Specification Perspective
  • The specification perspective is used to
    communicate interfaces that a class has
  • For example, the operations defined for the class
  • Class representations in this perspective most
    likely will not have attributes
  • The partially expanded form is often used
  • The perspective is suggesting behavior without
    the details of the behavior
  • This perspective will try to remain as language
    neutral as possible
  • Use of terms like Boolean are not taken
    literally

22
Class Diagrams Implementation Perspective
  • The implementation perspective is used to
    communicate the detailed design of the system
  • Class representations are one step away from
    source code
  • At this point, language or technology specific
    details may begin to materialize in the class
    representations
  • Full specifications of operations and attributes
    exist

23
Class Diagrams Our purposes
  • Many of the class diagrams we will discuss or
    generate will straddle the conceptual and
    specification perspective
  • This is often the focus of modeling
  • It is useful to begin modeling at the conceptual
    level and later evolve a specification perspective

24
Exercise
Generate two class diagrams (a conceptual view
and a specification view) which contain classes
for Cookbook Recipe Ingredient
Write a Comment
User Comments (0)
About PowerShow.com