`
bulote
  • 浏览: 1308472 次
文章分类
社区版块
存档分类
最新评论

Part 1: Introduction to OOAD

 
阅读更多
Part 1: Introduction to OOAD
2
Objectives
What we will learn:
 Introduce OO concepts.
 Compare and contrast analysis and design.
 Define object-oriented analysis and design
(OOA/D).
 Illustrate a brief example.
3
What Is Object Technology?
 A set of principles
(abstraction,
encapsulation,
polymorphism) guiding
software construction,
together with
languages, databases,
and other tools that
support those
principles. (Object
Technology - A
Manager’s Guide,
Taylor, 1997.)
4
The Strengths of Object Technology
 Reflects a single paradigm
 Facilitates architectural and code reuse
 Reflects real world models more closely
 Encourages stability
 Is adaptive to change
5
 Major object technology milestones
Simula
1967
C ++
Late 1980s
Smalltalk
1972
Java
1991
The UML
1996
UML 2
2004
The History of Object Technology
6
Where Is Object Technology Used?
 Client/Server Systems
and Web Development
 Object technology
allows companies to
encapsulate business
information in objects
and helps to distribute
processing across the
Internet or a network.
7
Where Is Object Technology Used? (continued)
 Real-time systems
 Object technology
enables real-time
systems to be
developed with higher
quality and flexibility.
4
8
Differences Between OO and Structured Design
 Object-orientation (OO)
 Melds the data and data flow process together
early in the lifecycle
 Has a high level of encapsulation
 Promotes reuse of code differently
 Permits more software extensibility
9
10
Concepts of Object Orientation
11
Objectives
 Describe abstraction, encapsulation,
modularity, and hierarchy.
 Describe the physical structure of a class.
 Describe the relationship between a class
and an object.
 Define polymorphism and generalization.
12
Where Are We?
 What is an object?
 Four principles of OO
 What is a class?
 Polymorphism and
generalization
 Organizing model elements
13
 Informally, an object represents an entity,
either physical, conceptual, or software.
 Physical entity
 Conceptual entity
 Software entity
Truck
Chemical Process
Linked List
What Is an Object?
14
A More Formal Definition
 An object is an entity
with a well-defined
boundary and identity
that encapsulates state
and behavior.
 State is represented by
attributes and
relationships.
 Behavior is represented
by operations, methods,
and state machines. Object
Operations
Attributes
15
An Object Has Identity
 Each object has a unique identity, even if the
state is identical to that of another object.
Professor “M Zheng”
teaches Java
Professor “M Zheng”
teaches Java
16
Where Are We?
 What is an object?
 Four principles of OO
 What is a class?
 Polymorphism and
generalization
 Organizing model elements
17
Basic Principles of Object Orientation
Abstraction
Hierarchy
Object Orientation
Encapsulation
Modularity
18
What Is Abstraction?
 The essential characteristics
of an entity that distinguishes
it from all other kinds of
entities.
 Defines a boundary relative to
the perspective of the viewer.
 Is not a concrete
manifestation, denotes the
ideal essence of something.
19
Example: Abstraction
Student Professor
Course Offering (9:00 a.m.,
Monday-Wednesday-Friday)
Course (e.g. Algebra)
20
What Is Encapsulation?
Improves Resiliency
 Hides implementation from clients.
 Clients depend on interface.
21
Encapsulation Illustrated
 Professor Clark
needs to be able
to teach four
classes in the
next semester.
SubmitFinalGrades()
AcceptCourseOffering()
TakeSabbatical()
Professor Clark
SetMaxLoad()
Name: Michael Zheng
Employee ID: 567138
HireDate: 07/25/1991
Status: Tenured
Discipline: Finance
MaxLoad:4 SetMaxLoad(4)
22
What Is Modularity?
 Breaks up something complex
into manageable pieces.
 Helps people understand
complex systems.
23
Example: Modularity
 For example, break
complex systems into
smaller modules. Billing
System
Course Registration
System
Course
Catalog
System
Student
Management
System
24
What Is Hierarchy?
Decreasing
abstraction
Increasing
abstraction
Asset
RealEstate
Savings
BankAccount
Checking Stock
Security
Bond
Elements at the same level of the hierarchy
should be at the same level of abstraction.
25
Where Are We?
 What is an object?
 Four principles of OO
 What is a class?
 Polymorphism and
generalization
 Organizing model elements
26
What Is a Class?
 A class is a description of a set of objects
that share the same attributes, operations,
relationships, and semantics.
 An object is an instance of a class.
 A class is an abstraction in that it
 Emphasizes relevant characteristics.
 Suppresses other characteristics.
27
A Sample Class
Class
Course
Properties
Name
Location
Days offered
Credit hours
Start time
End time
Behavior
Add a student
Delete a student
Get course roster
Determine if it is full
28
Representing Classes in the UML
 A class is represented using a rectangle
with three compartments:
 The class name
 The structure (attributes)
 The behavior (operations)
Professor
- name
- employeeID : UniqueId
- hireDate
- status
- discipline
- maxLoad
+ submitFinalGrade()
+ acceptCourseOffering()
+ setMaxLoad()
+ takeSabbatical()
+ teachClass()
29
What Is an Attribute?
 An attribute is a named property of a class
that describes the range of values that
instances of the property may hold.
 A class may have any number of attributes or no
attributes at all.
Attributes
Student
- name
- address
- studentID
- dateOfBirth
30
Attributes in Classes and Objects
Class
Objects
Student
- name
- address
- studentID
- dateOfBirth
:Student
- name = “Lei Wang”
- address = “123 Main St.”
- studentID = 9
- dateOfBirth = “03/10/1987”
:Student
- name = “Ning Li”
- address = “456 People St.”
- studentID = 2
- dateOfBirth = “12/11/1989”
31
Object-Oriented Basics: Class
 E.g. A chair is a member of (instance of) a set of similar
objects (class) that we call furniture.
class: Furniture
cost
dimensions
weight
location
color
buy
sell
weigh
move
object:
theChair
cost
dimensions
weight
location
color
buy
sell
weigh
move
32
What Is an Operation?
 A service that can be requested from an
object to effect behavior. An operation has
a signature, which may restrict the actual
parameters that are possible.
 A class may have any number of operations
or none at all.
Operations
Student
+ get tuition()
+ add schedule()
+ get schedule()
+ delete schedule()
+ has prerequisites()
33
Object-Oriented Basics: Messages
 Messages are the mechanism by which objects
(classes) interact.
object: receiver
object: sender
attributes:
attributes:
operations:
operations:
message: [receiver,
operation, parameters]
message: [sender,
return value(s)]
34
Where Are We?
 What is an object?
 Four principles of OO
 What is a class?
 Polymorphism and
generalization
 Organizing model elements
35
What Is Polymorphism?
 The ability to hide many different
implementations behind a single interface.
Manufacturer A
Manufacturer B Manufacturer C
OO Principle:
Encapsulation
Remote Control
36
Example: Polymorphism
Stock Bond Mutual Fund
getCurrentValue()
financialInstrument.getCurrentValue()
getCurrentValue()
getCurrentValue()
37
What Is Generalization?
 A relationship among classes where one
class shares the structure and/or behavior
of one or more classes.
 Defines a hierarchy of abstractions in which
a subclass inherits from one or more
superclasses.
 Single inheritance.
 Multiple inheritance.
 Is an “is a kind of” relationship.
38
Example: Single Inheritance
 One class inherits from another.
Savings Checking
Superclass
(parent)
Subclasses
(children)
Generalization
Relationship
Ancestor
Account
- balance
- name
- number
+ withdraw()
+ createStatement()
Descendents
39
Object-Oriented Basics: Inheritance
 Objects inherit from
the class all attributes
and operations.
class: Furniture
cost
dimensions
weight
location
color
buy
sell
weigh
move
object:
theTable
cost
dimensions
weight
location
color
buy
sell
weigh
move
object:
theChair
cost
dimensions
weight
location
color
buy
sell
weigh
move
40
Example: Multiple Inheritance
 A class can inherit from several other
classes.
Use multiple inheritance only when needed and
always with caution!
FlyingThing Animal
Airplane Helicopter Bird Wolf Horse
Multiple Inheritance
41
What Is Inherited?
Inheritance leverages the similarities among classes.
 A subclass inherits its parent’s attributes,
operations, and relationships.
 A subclass may:
 Add additional attributes, operations,
relationships.
 Redefine inherited operations. (Use caution!)
 Common attributes, operations, and/or
relationships are shown at the highest
applicable level in the hierarchy.
42
Where Are We?
 What is an object?
 Four principles of OO
 What is a class?
 Polymorphism and
generalization
 Organizing model elements
43
 A general purpose mechanism for
organizing elements into groups.
 A model element that can contain other
model elements.
 A package can be used:
 To organize the model under development.
 As a unit of configuration management.
What Is a Package?
University
Artifacts
44
A Package Can Contain Classes
 The package, University Artifacts, contains
one package and five classes.
University
Artifacts
CourseOffering
Schedule
Professor
Course
Student
Student
Artifacts
45
Diagram Depiction
<heading>
<contents area>
 Each diagram has a frame, a heading
compartment in the upper left corner, and a
contents area.
 If the frame provides no additional value, it may
be omitted and the border of the diagram area
provided by the tool will be the implied frame.
46
Review
 What is an object?
 What are the four principles of object
orientation? Describe each.
 What is a class? How are classes
and objects related?
 What is an attribute? An operation?
 Define polymorphism. Provide an
example of polymorphism.
 What is generalization?
 Why use packages?
47
Applying UML and Patterns in OOA/D
 Skills in object-oriented analysis and design (OOA/D) are
essential for the creation of well-designed, robust, and
maintainable software using object technologies and
languages such as Java, C++
What these skills are:
 Design Patterns - named problem-solution formulas that
codify exemplary design principles.
 They are best-practice principles to help us answer design
questions:
 Class Design - How to Assign Responsibilities to Classes?
How should classes interact? What classes should do what?
 UML - The UML is not OOA/D or a method, it is simply
notation.
48
Assign Responsibilities
 Fundamental ability in OOA/D is to skillfully assign
responsibilities to software components - classes
 Nine fundamental principles in object design and
responsibility assignment will be introduced later.
 OK, wait until we see them…
49
What Is Analysis and Design?
 Analysis
emphasizes an investigation of the
problem
and requirements
itresunqm
, rather than a
solution
"Analysis" is a broad term, best qualified, as in
requirements analysis
r eq u i r em en t s an al ysi s
(an investigation of the
requirements) or object analysis
o b j ect an al ysi s
(an investigation
of the domain objects).
 Design
emphasizes a conceptual solution
iltacsnou that
fulfills
the requirements
itreshu , rather than its
implementation.
50
Object-Oriented Processes: Analysis
 Define all classes (and relationships and behavior
associated with them) that are relevant to the
problem to be solved.
 Tasks:
 Communicate basic user requirements to SWE
 Identify classes (attributes & methods defined)
 Specify class hierarchy
 Represent object-to-object relationships
 Model object behavior
51
Object-Oriented Processes: Analysis Approaches
 Booch
 Coad & Yourdon
 Jacobson
 Rumbaugh
 Wirfs-Brock
 Formal Methods UUnniiffiieedd MMeetthhoodd
FFuussiioonn
52
Object-Oriented Processes: Design
 Transform the analysis model (created using OOA)
into a design model that serves as a blueprint for
software construction.
 Phases:
 High-level — (sub)system design phase
 Low-level — object design phase
53
Object-Oriented Processes: Design Goals
 Describe characteristics of the subsystems
required to implement customer requirements and
the needed support environment.
 OOD enables a software engineer to
 indicate the objects that are derived from each
class
 how these objects interrelate with one another
 OOD depicts how
 relationships among objects are achieved
 behavior is to be implemented
 communication among objects is to be
implemented
54
Review: What is OOA/D
 Object-oriented analysis
is about finding and describing
the objects—or concepts—in the problem domain
 object-oriented design
is about defining software
objects and how they collaborate to fulfill the
requirements.
B o o k
t i t l e
public class Book
{
private String title ;
public Chapter getChapter (i n t )
{. . . }
}
domain concept
visualization
of domain
concept
representation in an
object -oriented
programming language
55
Procedural vs Object-Oriented
 Instead of programming the computer to do
calculation (in mathematical functions), OO
programming attempts to model interacting
components
to build a solution.
 In similar ways, traditional structured ISAD also
differs from OOAD.
56
Structured ISAD vs OOAD
• Structured ISAD
– functional decomposition
• OOAD
– object decomposition: discover the
objects, and assign proper responsibilities
ircsntspi

57
An Simple Example
 We will design a simple program by going through
the basic OOAD steps to demonstrate how to
OOAD in short.
 Example – Design a small program to simulate a
"dice game" in which a player rolls two die. If the
total is seven, they win; otherwise, they lose.
58
Define Use Cases
 Requirements analysis may include a description of related
domain processes, these can be written as use cases.
 Use Cases are a popular tool in requirements analysis to
capture the functional aspects of requirements
 Use cases are not an object-oriented
 There are different ways to write Use Cases. Here, we use
a narrative statement method - simply written stories. More
methods will be introduced later.
Use case: Play a Dice Game
A player picks up and rolls the dice. If the dice face
value total seven, they win; otherwise, they lose.
59
Define a Domain (Analysis) Model
 Object-oriented analysis
is concerned with creating a
description of the domain from the perspective of
classification by objects – expressed as a domain model.
 Domain model
 Defining a domain model involves identifying:
concepts,
attributes,
associations
. Player
nam e
DiceGame
D ie
faceValue
R o lls
P la ys
Includes
2
2
1
1
1
1
60
Define Interaction Diagrams
 Object-oriented design is concerned with defining software
objects and their collaborations.
 A common notation to illustrate these collaborations is the
interaction diagram.
 It shows the flow of messages between software objects, and thus
the invocation of methods.
:D iceGame
play()
die1 : D ie
fv1 := getFaceValue()
die2 : D ie
roll()
roll()
fv2 := getFaceValue()
61
Define Design Class Diagrams
 Interaction diagrams
gives a dynamic
d y n a m i c
view
of
collaborating objects
 It is useful to create a static
s t a t i c
view
of the class definitions
with a design class diagram i
n addition to interaction
diagrams
2
D ie
faceValue : int
getFaceValue() : int
roll()
DiceGame
die1 : Die
die2 : Die
play()
1
分享到:
评论

相关推荐

    UML和OOAD快速入门

    资源名称:UML和OOAD快速入门 内容简介:本书是UML和OOAD的初学者指南。本书介绍了分析师必学的3种UML图:类图、用例图和序列图,以及3种最实用、最常用的OOAD概念和工具:事务模式、用例描述、BCE模式。通过贯穿...

    OOAD:仅用于 OOAD 练习

    面向对象仅用于OOAD练习 练习11文件夹与第10章文件夹有点不同 仅用于Web界面奖励 1.断行代码为 loader.brokeLine("The line name"); 2.断站代码是loader.brokeStation("The station name"); 将其中一个或两个放在 ...

    vehicle-registration-system:PES University OOAD&SE课程的一部分

    PES大学的OOAD&SE课程的一部分。 根据提供的SRS所需的功能。 主窗口和登录 新车注册 交易记录 临时车辆登记 搜索车辆详细信息 更新详情 如何克隆和运行它? 首先使用下面提到的命令克隆此仓库。 git clone ...

    OOAD第二章1

    OOAD第二章分区 OOAD第二章 的第 1 页

    UML Applied: A .NET Perspective(2)

    Chapter 6 - Step 1: Define Your Requirements Chapter 7 - Step 2: Refine Your Requirements Chapter 8 - Step 3: Assign Your Requirements to Components and Interfaces Chapter 9 - Step 4: Design ...

    UML Applied: A .NET Perspective(1)

    Chapter 6 - Step 1: Define Your Requirements Chapter 7 - Step 2: Refine Your Requirements Chapter 8 - Step 3: Assign Your Requirements to Components and Interfaces Chapter 9 - ...

    OOAD面向对象编程

    OOAD 面向对象编程~~

    OOAD第十章1

    OOAD第十章分区 OOAD第十章 的第 1 页

    C++OOAD的设计原则

    OO设计原则是设计模式的基础,该资源包括OOAD的设计原则 LSP OCP SRP ISP DIP原则及UML说明

    OOAD课堂练习作业和代码

    OOAD课堂练习作业和代码

    西北农林科技大学OOAD实习

    西北农林科技大学OOAD实习西北农林科技大学OOAD实习西北农林科技大学OOAD实习西北农林科技大学OOAD实习

    OOAD & UML

    OOAD & UML 达内科技·项目部卢剑宇2007-11-29 一、基本内容: OOA/D 面向对象的分析与设计。方法论、哲学; 架构师、项目经理、设计人员 OOA ——Object Oriented Analysis 面向对象的分析,以业务为中心来分析解决...

    OOAD第六章1

    OOAD第六章分区 OOAD第六章 的第 1 页

    OOAD第九章1

    OOAD第九章分区 OOAD第九章 的第 1 页

    OOAD+UML学习笔记

    对OOAD和UML指导思想的基本概述,欢迎大家下载学习,也希望各位继续完善

    OOAD教师用书(IBM 原厂)word版

    IBM原厂的OOAD教师用书,内容非常详细,容易读懂。

    第一次OOAD作业1

    第一次OOAD作业1

    OOAD课件.doc

    OOAD各知识点精华。初学者必看资料!!!

Global site tag (gtag.js) - Google Analytics