Upload
nguyen-tran
View
823
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 1
Introduction to Rational Rose 98i
Module 4: Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 2
Objectives: Class Diagram
You will be able to: Create classes Add attributes and operations to classes Create stereotypes for classes Create packages Relocate classes Create class diagrams Create relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 3
Classes in the Browser
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 4
Namespaces
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 5
Documenting Classes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 6
Using the Class Specification - Stereotypes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 7
Using the Class Specification - Attributes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 8
Using the Class Specification - Operations
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 9
Attributes and Operations and the Browser
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 10
Attribute Visibility Options
NewClassPublic attributeProtected attributePrivate attribute
NewClass+ Public attribute# Protected attribute- Private attribute
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 11
Operation Visibility Options
NewClass
Public operation()Protected operation()Private operation()
NewClass
+ Public operation()# Protected operation()- Private operation()
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 12
Packages in the Browser
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 13
Moving Classes to Packages
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 14
What is a Class Diagram?
A class diagram is a view of the static structure of a system Models contain many class diagrams
Class diagrams contain: Packages, classes, interfaces, and
relationships Notation:
Package Name
Class NameInterface Name
<<Interface>>
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 15
The Main Class Diagram
The logical view initially contains one class diagram This diagram is called Main
The Main class diagram is typically a view of the high level packages in the logical view
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 16
Class Diagram Drawing Toolbar
Text
Attachment
Association Relationship
Association Attribute
Dependency Relationship
Inherits Relationship
Package
Selection Tool
Note
Class
Aggregation Relationship
Interface
Realizes Relationship
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 17
Main Class Diagram-Registration System
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 18
Main Diagram Business Services Package
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 19
Creating Classes on a Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 20
Class Name Completion
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 21
Creating Attributes via a Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 22
Creating Operations via a Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 23
Additional Class Diagrams
Additional class diagrams are added as needed
They show additional “views” of the packages and classes in the model
Examples: View of classes participating in a scenario View of the “private” classes in the package View of one or more classes and their
attributes and operations View of an inheritance hierarchy
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 24
Additional Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 25
Showing Stereotypes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 26
Color
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 27
Displaying Attributes and Operations
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 28
Displaying the Operation Signature
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 29
Displaying Visibility
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 30
Relationships
Class diagrams may contain the following relationships: Association, aggregation, dependency, realize,
and inheritance Notation:
Association Aggregation Dependency
Inheritance Realize
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 31
Package Relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 32
Class Relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 33
Navigation
Unidirectional
Bi-directional
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 34
Associations / Aggregations in the Browser
Navigable
Not Navigable
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 35
Naming Associations
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 36
Role Names
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 37
Zero or more0..*
One or more1..*
Zero or one0..1
Specified range2..7
Exactly one1
Multiplicity Indicators
Each end of an association or aggregation contains a multiplicity indicator Indicates the number of objects participating in
the relationship
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 38
Multiplicity Indicators
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 39
Aggregation Indicators
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 40
Reflexive Relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 41
Constraints
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 42
Qualifiers
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 43
Association Classes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 44
Deleting
If a package, class, association, or aggregation is deleted from the Browser then it is deleted from the model
If a package, class, association, or aggregation is deleted from a Class Diagram, it is deleted from the diagram but still remains in the model
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 45
Exercise: Classes
Use the pictures on the following pages to create the packages, classes, and class diagrams for your model
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 46
Exercise: Classes in the Browser
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 47
Exercise: Documenting Classes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 48
Exercise: Stereotypes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 49
Exercise: Packages in the Browser
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 50
Exercise: Relocating Classes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 51
Exercise: Creating Attributes
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 52
Exercise: Creating Operations
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 53
Exercise: The Main Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 54
Exercise: Package Main Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 55
Exercise: Additional Class Diagram
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 56
Exercise: Displaying Attributes/Operations
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 57
Exercise: Relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 58
Exercise: Relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 59
Exercise: Reflexive Relationships
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 60
Exercise: Role Names
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 61
Exercise: Multiplicity
Introduction to Rational Rose 98i v 5.2Copyright 1993-1999 Rational Software, all rights reserved 62
Exercise: Constraints