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
【直流微电网】径向直流微电网的状态空间建模与线性化:一种耦合DC-DC变换器状态空间平均模型的方法 (Matlab代码实现)内容概要:本文介绍了径向直流微电网的状态空间建模与线性化方法,重点提出了一种基于耦合DC-DC变换器状态空间平均模型的建模策略。该方法通过对系统中多个相互耦合的DC-DC变换器进行统一建模,构建出整个微电网的集中状态空间模型,并在此基础上实施线性化处理,便于后续的小信号分析与稳定性研究。文中详细阐述了建模过程中的关键步骤,包括电路拓扑分析、状态变量选取、平均化处理以及雅可比矩阵的推导,最终通过Matlab代码实现模型仿真验证,展示了该方法在动态响应分析和控制器设计中的有效性。; 适合人群:具备电力电子、自动控制理论基础,熟悉Matlab/Simulink仿真工具,从事微电网、新能源系统建模与控制研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握直流微电网中多变换器系统的统一建模方法;②理解状态空间平均法在非线性电力电子系统中的应用;③实现系统线性化并用于稳定性分析与控制器设计;④通过Matlab代码复现和扩展模型,服务于科研仿真与教学实践。; 阅读建议:建议读者结合Matlab代码逐步理解建模流程,重点关注状态变量的选择与平均化处理的数学推导,同时可尝试修改系统参数或拓扑结构以加深对模型通用性和适应性的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值