Anda di halaman 1dari 14

Object-Oriented Analysis and

Design Using the Unified


Modeling Language
Student Guide

2.0
20011GC20
M013166

Authors

Copyright Oracle Corporation, 2000. All rights reserved.

Kate Heap

This documentation contains proprietary information of Oracle Corporation. It is


provided under a license agreement containing restrictions on use and disclosure and
is also protected by copyright law. Reverse engineering of the software is prohibited. If
this documentation is delivered to a U.S. Government Agency of the Department of
Defense, then it is delivered with Restricted Rights and the following legend is
applicable:

Tom Richards

Restricted Rights Legend


Use, duplication or disclosure by the Government is subject to restrictions for
commercial computer software and shall be deemed to be Restricted Rights software
under Federal law, as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013,
Rights in Technical Data and Computer Software (October 1988).
This material or any portion of it may not be copied in any form or by any means
without the express prior written permission of the Education Products group of Oracle
Corporation. Any other copying is a violation of copyright law and may result in civil
and/or criminal penalties.
If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with Restricted Rights, as defined in FAR
52.227-14, Rights in Data-General, including Alternate III (June 1987).
The information in this document is subject to change without notice. If you find any
problems in the documentation, please report them in writing to Worldwide Education
Services, Oracle Corporation, 500 Oracle Parkway, Box SB-6, Redwood Shores, CA
94065. Oracle Corporation does not warrant that this document is error-free.
Oracle and all references to Oracle Products are trademarks or registered trademarks
of Oracle Corporation.
All other products or company names are used for identification purposes only, and
may be trademarks of their respective owners.

Contents

Lesson 1
Objectives 1-2
Todays Challenges 1-4
How Can Object Technology Help? 1-5
The Promise of Object Orientation 1-9
Where Can Objects be Used? 1-11
Development Methods and Tools 1-13
What Is an Object Oriented Method? 1-14
Modeling the Real World 1-15
Examples of OO Methods 1-16
New Terms, Old Ideas 1-17
What is UML? 1-18
Closing Thoughts 1-19
Summary 1-20
Lesson 2
Objectives 2-2
What Is an Object? 2-3
A Database Analogy 2-4
Objects Perform Operations 2-5
Objects Remember Values 2-6
Objects Are an Abstraction 2-7
Encapsulation and Information-Hiding 2-8
Examples and Benefits 2-9
Class Discussion:
Spot the Operations and Attributes 2-10
How Objects Interact -- Messages 2-11
The Donut Diagram 2-12
Objects Associate with Each Other 2-13
How Many Objects Are in an Association? 2-14
Object Composition 2-15
More on Composition 2-16
Where Objects Come From -- Classes 2-17
Why Do We Need Classes? 2-18

iii

Classes Versus Objects 2-19


Class Discussion:
What Classes Could These Objects Belong To? 2-20
Classification and Inheritance 2-22
Subclasses and Superclasses 2-23
Inheritance 2-24
Example Class Hierarchy 2-25
More on Inheritance 2-26
Generalization 2-27
The Is-a-Kind-of Relationship 2-28
Polymorphism 2-29
Polymorphism II 2-30
Example of Polymorphism 2-31
Summary 2-32
Practice 2-1 Overview 2-33
Introduction to UML Notation 2-34
What Objects Are Involved? 2-35
More About the Allocation Manager 2-36
Allocation Manager Operations 2-37
More About Room Types 2-38
Room Category Operations 2-39
More About Rooms 2-40
Room Operations 2-41
Playing the Game 2-42
Sample Allocation of Roles 2-43
Playing the Game 2-44
Extensions 2-45

iv

Lesson 3
Objectives 3-2
Phases of a Project 3-3
The Traditional Waterfall Life Cycle 3-5
The Iterative Life Cycle 3-7
Iterative Development 3-8
Incremental Delivery 3-9
OO DevelopmentThe Micro Process 3-10
OO DevelopmentThe Macro Process 3-11
Goals of OO Analysis and Design 3-13
OO Analysis Overview 3-14
OOAPeople and Tools 3-15
OO Design Overview 3-16
Design Overview, continued 3-17
OODPeople and Tools 3-18
OO Implementation Overview 3-19
ImplementationPeople and Tools 3-21
Implementation Languages and Tools 3-22
Popular OO Programming Languages 3-24
Smalltalk 3-26
C++ 3-28
Java 3-29
Benefits of Java 3-31
Summary 3-32
Lesson 4
Objectives 4-2
The Problem of Misunderstood Scope 4-3
Specifying System Behavior 4-4
Use Cases Solution 4-5
What Is an Actor? 4-6
Actors 4-7
Describing Actors 4-8
Sample Actor 4-9
The CarsRUs Case Study 4-10
The CarsRUs Case Study 4-11
Practice 4:1 Identifying Actors 4-12
Introducing Use Cases 4-13
What is a Use Case? 4-14
Identifying Use Cases 4-15

Purpose of Use Cases 4-16


Purpose of Use Cases, Part 2 4-17
Developing Use Cases 4-18
Documenting Use Cases 4-19
Describing Use Cases 4-20
Sample Use Case 4-21
Use Case Diagrams 4-22
Summary 4-23
Practice 4:2 Creating Use Case Diagrams 4-24
Advanced Topic: Managing Complexity 4-25
Generalizing and Specializing Actors 4-26
Packaging Use Cases 4-27
Generalization of Use Cases (Uses) 4-28
The Extend Relationship 4-30
Stereotypes 4-31
Meta-Classification 4-32
Lesson 5
Objectives 5-2
Facts About Scenarios 5-3
Sample Scenarios 5-4
More About Scenarios 5-7
Purpose of Scenarios 5-8
To Infinity and Beyond 5-9
When to Stop Defining Scenarios 5-10
Sample Scenarios 5-11
Always Model the Logical Interface 5-12
Developing Scenarios 5-13
Summary 5-14
Practice 5:1 Identifying Scenarios 5-15

vi

Lesson 6
Objectives 6-2
Domain Object Model 6-4
Class Models 6-6
A Class Diagram 6-7
Class Diagrams Compared to ER Diagrams 6-9
Classes in UML 6-10
UML Class Diagrams - Association 6-11
A Class Is a Blueprint for Objects 6-14
Discovering Classes 6-15
Identifying Classes 6-16
Nouns and Noun Phrases 6-17
Whiteboard and Post-It Notes 6-18
Organizing Classes Spatially 6-19
Removing Synonyms 6-20
Remember the System Boundary 6-21
Demoting Unimportant Nouns 6-22
Brainstorming New Classes 6-23
Additional Filtering Criteria 6-24
Documenting the Domain Model 6-25
Describing Classes 6-26
How Much Detail is Needed? 6-27
Revised List of Supermarket Classes 6-28
What is Left in the Class Diagram? 6-29
Example: Class Descriptions 6-30
Practice 6-1: Identifying Classes 6-31
Identifying Associations 6-33
Summary 6-34
Practice 6-2: Creating the Class Diagram 6-35

vii

Lesson 7
Objectives 7-2
Review of OO Analysis 7-3
Moving into OO Design 7-4
Exploratory Design Activities 7-5
Refining the Design 7-6
Design Artifacts 7-7
OO Analysis or OO Design? 7-8
Example of OOA Versus OOD 7-9
OO Design Map 7-10
Designing Classes and Associations 7-11
Designing for Inheritance 7-13
Designing for Reuse 7-14
Patterns 7-16
What is a Pattern? 7-17
Summary 7-18
Lesson 8
Objectives 8-2
Why Architecture? 8-3
Technical Architecture Issues 8-4
Additional Technical Architecture 8-5
The Project Architect 8-6
Subsystems 8-7
Subsystems and Packages 8-8
Logical Software Architecture 8-9
Packages 8-10
Package Contents 8-11
Referencing 8-12
Package Design 8-13
Service Packages 8-14
Identifying Packages 8-15
Physical Software Architecture 8-16
Hardware Architecture 8-17
Deployment Diagrams 8-18
Software Deployment 8-19
Considering Deployment Options 8-20
A Three-tier Architecture 8-21
Object Persistence 8-22
Database Connectivity 8-23
Object-Relational Mapping 8-24
Persistence Layers 8-25
Summary 8-26

viii

Lesson 9
Objectives 9-2
The Design Model 9-3
Design Classes 9-4
Well-Formed Classes 9-5
Discovering Design Classes 9-6
CRC Cards 9-7
New Classes 9-9
Guidelines For Assigning Class Responsibilities 9-10
Guidelines for Collaborations 9-11
Collaboration Patterns 9-12
Sequence Diagrams 9-13
A Sequence Diagram 9-14
Another Sequence Diagram 9-15
Objects in Sequence Diagrams 9-16
Messages in a Sequence Diagram 9-17
Creating Sequence Diagrams 9-18
Controller Objects 9-19
Looking for Hidden Objects 9-20
Guidelines for Sequence Diagrams 9-21
Practice 9-1: Creating a Sequence Diagram 9-22
Finding Associations 9-23
Naming Associations 9-24
Finding Operations 9-26
Naming Operations 9-27
Guidelines for Operations 9-28
Practice 9-2: Defining Parameters 9-29
Sample Solution 9-30
Summary 9-31
Practice 9-3: Updating the Class Diagram 9-32

Lesson 10
Objectives 10-2
State Definition 10-3
State 10-4
States and Events 10-5
UML State Transition Diagrams 10-6
State Diagramming Notation 10-7
Example: State Transition Diagram 10-8
Identifying States and Events 10-9
Identifying States and Events 10-10
First Cut State Diagram 10-11
State Diagram, Alternative Courses 10-12
Events and Behavior 10-13
Example: Action-Expressions 10-14
Entry and Exit Actions 10-15
Example: Entry and Exit Actions 10-16
Guard Conditions 10-17
Automatic Transitions 10-18
Guarded Automatic Transitions 10-19
Internal Actions 10-20
Self Transitions 10-21
State Variables 10-22
State Box with Regions 10-23
State Transition Table 10-24
Example: State Transition Table 10-25
Summary of Actions 10-26
Activity Diagrams 10-27
Activity Diagram Symbols 10-28
An Activity Diagram 10-29
Summary 10-30
Optional Practice 10-31
Exercise: Sequence Diagram 1 10-32
Exercise: Sequence Diagram 2 10-33
Exercise: Sequence Diagram 3 10-34
Exercise: Sequence Diagram 4 10-35
Answer: State Transition Diagram 10-36
Answer: Missing Events 10-37

xi

Lesson 11
Objectives 11-2
Associations: A Recap 11-4
Object Links 11-5
Collaboration Diagrams 11-6
Links in Collaboration Diagrams 11-7
Designing Associations 11-8
Classifying Relationships 11-9
Association Directionality (Navigability) 11-10
Multiplicity 11-12
Multiplicity Notation 11-13
Class Discussion: Multiplicity Examples 11-14
Implications Of Multiplicity 11-15
Determining Multiplicity 11-16
Class Practice: Multiplicity Exercise 11-17
Class Practice: Sample Solution 11-18
Multiplicity and Collections 11-19
Collections 11-20
Using Collection Classes 11-22
Class Discussion: Which Collection? 11-23
Constraints and Notes 11-24
Association Classes 11-25
Reflexive Associations 11-26
Aggregation in UML 11-27
Aggregation 11-28
Composite Aggregation 11-29
Composite AggregationExample 1 11-30
Composite AggregationExample 2 11-31
Shared Aggregation 11-32
Class Discussion: Shared or Composite? 11-33
Using Composite Aggregation 11-34
Using Shared Aggregation or Association 11-35
The Need to Define Associations 11-36
Summary 11-37
Practice 11-1:Defining Associations 11-38
Practice 11-2:Specifying Associations 11-39
Suggested Solution 11-40
Suggested Solution 2 11-41

xii

Lesson 12
Objectives 12-2
Design Refinement 12-3
Language Support for Classes 12-4
Creating Classes in Java 12-5
Using Classes in Java 12-6
Packages in Java 12-7
Class Specifications 12-8
Class Discussion: Specifying Classes 12-9
Partial Class Specification 12-10
Class Design Checklist 12-11
Designing Operations 12-12
Stereotypes 12-14
Stereotyping Operations 12-16
Attributes 12-17
Designing Attributes 12-18
Designing Attributes for Java 12-19
Constraints 12-20
Designing Attributes 12-21
Encapsulation and Information-Hiding 12-22
Visibility in UML 12-23
Attribute Visibility and Access 12-24
Class Variables and Methods 12-25
Summary 12-26
Practice 12-1: Defining Attributes and Operations 12-27
Lesson 13
Objectives 13-2
What is Inheritance? 13-4
Inheritance in Analysis and Design 13-5
Sample Inheritance Hierarchy 13-7
Inheritance Terminology 13-8
Notation for Inheritance 13-9
Specifying Inheritance in Java 13-10
Finding Inheritance: Specialization 13-11
Finding Inheritance: Generalization 13-12
Abstract Classes 13-13
Alternative Representation 13-15
Abstract Operations 13-16
Abstract Classes and Methods in Java 13-17

xii

Multilevel Inheritance Hierarchies 13-18


The Substitution Rule 13-19
Goals of Inheritance 13-20
Refining Inheritance 13-21
Practice 13-1:Identifying Inheritance Relationships 13-22
Multiple Inheritance 13-23
Multiple Inheritance 13-24
Interfaces Instead of Multiple Inheritance 13-25
Interfaces 13-26
Interfaces in Java 13-28
What Is Polymorphism? 13-29
Advantages of Polymorphism 13-30
Static Binding Versus Dynamic Binding 13-31
Example of Polymorphism in Java 13-32
A Subsystem 13-33
Identifying Subsystems 13-34
Refinement Summary 13-35
Summary 13-36
Lesson 14
Objectives 14-2
A Succession of Models 14-3
Object Oriented Methods 14-4
OO Analysis 14-5
OO Design 14-6
OO Implementation 14-7
Code Generation 14-8
Testing 14-9
Oracle JDeveloper 14-10
Iterative Development 14-11
OO Methodology 14-12
The Promise of Object Orientation 14-13
How Are Objects Different? 14-14
How Are Objects Different, continued 14-15
For Further Study 14-17

xii

Appendix A Car Rental System Sample Solution


Identifying Actors (Practice 4:1) A-2
Use Case Diagram (Practice 4:2) A-3
Use Case Diagram with Packages A-4
Use Cases (Practice 4:2) A-5
Use Cases (Practice 4:2) A-6
Use Cases A-7
Use Cases (Practice 4:2) A-8
Scenarios (Practice 5:1) A-9
Scenarios (Practice 5:1) A-10
Scenarios A-11
Identifying Classes (Practice 6:1) A-13
Organizing Classes Spatially (Practice 6:1) A-14
Example Class Descriptions (Practice 6:1) A-15
Example Class Descriptions A-16
Sequence Diagrams (Practice 9:1) A-17
Sequence Diagrams (Practice 9:1) A-18
Class Diagram (Practice 9:3) A-19
Appendix B Object-to-Relational
Mapping Techniques
Objectives B-2
Object Persistence B-3
RDBMS Fundamentals B-4
Primary and Foreign Keys B-5
ID Attributes B-6
Mapping the Object Model B-7
Implementing Classes B-8
Implementing Associations B-9
Many-to-Many Associations B-10
Implementing Link Attributes B-11
RDBMS Storage Model B-13
Object Database Model B-14
ODMG-93 Standard B-15
ODMG-93 Object Model B-16
ODMG-93 Object Model: Example B-17
Programming Language Bindings B-18
RDBMS or ODBMS? B-19
Summary B-20
Appendix C Reading List

xii