OOA和OOD的合理解释

1.第一讲:

1.OOA和OOD到底是什么?

OOA:全称Object-Oriented Analysis,面向对象分析方法。

在百度上查了几篇,发现讲的都大同小异,而且于我而言较为晦涩,生词太多。所以通过查阅专业书籍,资料,加上自己的理解,这里记录如下:

OOAD,Object-oriented analysis and design: is a popular technical approach for analyzing and designing an application, system, or business by applying object-oriented programming, as well as using visual modeling throughout the development life cycles to foster better stakeholder communication and product quality. [1]

意思就是:面向对象的分析和设计是一种流行的“技术”(这才是本质定义:技术),用来干什么的呢?用来分析,设计应用,系统或者业务。具体怎么实现呢?通过应用OOP(object-oriented programming 面向对象编程),以及使用贯穿开发生命周期的可视化建模来促进更好的利益相关者交流和产品质量。

根据指导书Unified Process (a popular iterative and incremental software development process framework) [2],OOAD is best conducted in an iterative and incremental way. The outputs of OOAD activities, analysis models for OOA and design models for OOD respectivenely, will be refined and evolve continuously driven by key factors like risks and business value. (这一段实在太精彩,我就不翻译了,翻译出来显得不美。同理,有些没必要翻译的句子,我也不翻译)

在上世纪90年代中期(mid-1990s),有很多相互争斗的软件开发方法和面向对象建模方法,通常和各大公司联系起来,由于缺乏标准,所以导致交流效率减退,并使得学习曲线变长。

1994年,the Three Amigos of Rational Software started working together to develop the Unified Modeling Language (UML).

软件生命周期一般被分为几个阶段:问题的抽象描述-》设计-》code and testing-》deployment部署。
分析和设计是最早的阶段。分析阶段也就“requirement acquisition”,需求获取。

  • 最开始,瀑布模型,waterfall models. fairly rigid and sequential, just like a “waterfall”.
  • 然后,迭代模型,iterative models. The emphasis on iterative models is that software development is a knowledge-intensive process and that things like analysis can’t really be completely understood without understanding design issues, that coding issues can affect design, that testing can yield information about how the code or even the design should be modified, etc.

Although it is possible to do object-oriented development using a
waterfall model, in practice most object-oriented systems are
developed with an iterative approach. As a result, in object-oriented
processes “analysis and design” are often considered at the same time.

The object-oriented paradigm emphasizes modularity and re-usability.

If the module provides standardized ways to add new behaviors or describe new states. In the object-oriented paradigm this is often accomplished by creating a new subclass of an existing class.
原来如此,每次添加功能,那就新建一个子类。这个很强。

The distinction between analysis and design is often described as “what vs. how”.
这里就说出了OOA和OOD的区别。

具体的
In object-oriented analysis this is typically done via use cases and abstract definitions of the most important objects. The subsequent design phase refines the analysis model and makes the needed technology and other implementation choices. In object-oriented design the emphasis is on describing the various objects, their data, behavior, and interactions. The design model should have all the details required so that programmers can implement the design in code.

Object-oriented analysis
The purpose of any analysis activity in the software life-cycle is to create a model of the system’s functional requirements that is independent of implementation constraints.

OOA和其他analysis 方法的区别

The main difference between object-oriented analysis and other forms
of analysis is that by the object-oriented approach we organize
requirements around objects, which integrate both behaviors
(processes) and states (data) modeled after real world objects that
the system interacts with. In other or traditional analysis
methodologies, the two aspects: processes and data are considered
separately. For example, data may be modeled by ER diagrams, and
behaviors by flow charts or structure charts. [1]


Common models used in OOA are use cases and object models. Use cases
describe scenarios for standard domain functions that the system must
accomplish. Object models describe the names, class relations (e.g.
Circle is a subclass of Shape), operations, and properties of the main
objects. User-interface mockups or prototypes can also be created to
help understanding. 就是说在OOA中,主要搞得是use case(用例:描述场景)和object
models(描述名字,类的关系,操作,性质等等)。


During object-oriented design (OOD), a developer applies
implementation constraints to the conceptual model produced in
object-oriented analysis. Such constraints could include the hardware
and software platforms, the performance requirements, persistent
storage and transaction, usability of the system, and limitations
imposed by budgets and time. Concepts in the analysis model which is
technology independent, are mapped onto implementing classes and
interfaces resulting in a model of the solution domain, i.e., a
detailed description of how the system is to be built on concrete
technologies.[6]

Important topics during OOD also include the design of software
architectures by applying architectural patterns and design patterns
with object-oriented design principles.

1.1 总结

我觉得OOA和OOD常常是摆在一起的。
OOA是需求获取,有关用例和对象模型(最重要对象的抽象定义)。数据和行为是被整合到一起的。是为了给系统功能性需求建模(独立于具体实现约束)。
OOD是紧接OOA之后的,细化了分析模型,并且在具体实现(技术)上做决定。重点描述不同对象,他们的数据,行为和交互。设计模型应该具有所有的细节(以供程序员实现他们的代码)。会设计硬件,软件平台,性能需求,存储,可用性,预算和时间上的限制。

1.2 题外话

1)面向对象(Object-Oriented)和面向过程(process oriented)的区别:
面向过程与面向对象,例如五子棋,面向过程的设计思路就是首先分析问题的步骤:1、开始游戏,2、黑子先走,3、绘制画面,4、判断输赢,5、轮到白子,6、绘制画面,7、判断输赢,8、返回步骤2,9、输出最后结果。把上面每个步骤用不同的方法来实现。

如果是面向对象的设计思想来解决问题。面向对象的设计则是从另外的思路来解决问题。整个五子棋可以分为1、黑白双方,这两方的行为是一模一样的,2、棋盘系统,负责绘制画面,3、规则系统,负责判定诸如犯规、输赢等。第一类对象(玩家对象)负责接受用户输入,并告知第二类对象(棋盘对象)棋子布局的变化,棋盘对象接收到了棋子的变化就要负责在屏幕上面显示出这种变化,同时利用第三类对象(规则系统)来对棋局进行判定。

面向过程就是分析出解决问题所需要的步骤,然后用函数把这些步骤一步一步实现,使用的时候一个一个依次调用就可以了。
面向对象是把构成问题事务分解成各个对象,建立对象的目的不是为了完成一个步骤,而是为了描叙某个事物在整个解决问题的步骤中的行为。 [3]

但我觉得这些解释还不够,这里再引用一段英文解释

**Procedural Programming**
Procedural programming uses a list of instructions to tell the computer what to do step-by-step. Procedural programming relies on - you guessed it - procedures, also known as routines or subroutines. A procedure contains a series of computational steps to be carried out. Procedural programming is also referred to as imperative programming. Procedural programming languages are also known as top-down languages.

Procedural programming is intuitive in the sense that it is very similar to how you would expect a program to work. If you want a computer to do something, you should provide step-by-step instructions on how to do it. It is, therefore, no surprise that most of the early programming languages are all procedural. Examples of procedural languages include Fortran, COBOL and C, which have been around since the 1960s and 70s.

**Object-Oriented Programming**
Object-oriented programming, or OOP, is an approach to problem-solving where all computations are carried out using objects. An object is a component of a program that knows how to perform certain actions and how to interact with other elements of the program. Objects are the basic units of object-oriented programming. A simple example of an object would be a person. Logically, you would expect a person to have a name. This would be considered a property of the person. You would also expect a person to be able to do something, such as walking. This would be considered a method of the person.

A method in object-oriented programming is like a procedure in procedural programming. The key difference here is that the method is part of an object. In object-oriented programming, you organize your code by creating objects, and then you can give those objects properties and you can make them do certain things.

A key aspect of object-oriented programming is the use of classes. A class is a blueprint of an object. You can think of a class as a concept and the object as the embodiment of that concept. So, let's say you want to use a person in your program. You want to be able to describe the person and have the person do something. A class called 'person' would provide a blueprint for what a person looks like and what a person can do. Examples of object-oriented languages include C#, Java, Perl and Python.

**Key Differences**
One of the most important characteristics of procedural programming is that it relies on procedures that operate on data - these are two separate concepts. In object-oriented programming, these two concepts are bundled into objects. This makes it possible to create more complicated behavior with less code. The use of objects also makes it possible to reuse code. Once you have created an object with more complex behavior, you can use it anywhere in your code.

就是说,面向过程是step by step的,procedure和data是分开的。
OOP是基于object(对象)的,所有操作都用object来完成,method和PP中的procedure一样,但是method被整合在了object中。因为类的使用,导致可重用性变高。所以面向对象是很不错的啦。

1.3 再补充(OOA&OOD)

面向对象分析(Object Oriented Analysis):是一种以对象为中心的编程思想。利用从问题域中的词汇表中找到类与对象。那么说到这里,很多人对问题域又不是很清楚了,问题域:说的简单直接一点,问题域就是客户告诉你的要求,他要干什么。问题域并不特指需求,很多时候,客户所提的需求很多地方都有关联,所以在很多场合,客户所提的需求,还需要需求分析师多角度的帮助客户理清与完善。那么在客户需求范围中,衍生出来的他想要告诉你做的事,就是问题域,包括后期需求发生的变化,同样隶属于问题域的范围。

抽离出来的类型有:汇钱者类,收钱者类,货币类。而张三只能算是汇钱者类中的一个实例,也被称之为汇钱者对象,李四只能算是一个收钱者类中的一个实例,也被称之为收钱者对象。那么额度为5000的人民币也只是货币类的一个具体实例。通常汇钱者类,收钱者类,货币类,我们都统一称之为:领域模型类,张三,李四,5000元人民币我们都统一称之为:领域对象。作为面向对象分析来说,我们最为重要的就是要分析出领域对象的行为。领域对象的行为主要是为后期的面向对象设计(OOD)提供接口依据,而属性作为分析阶段不是我们的重点。

领域模型(面向对象设计 OOD)(Object Oriented Design):主要是正确有效的构造出复杂系统的抽象结构,将面向对象分析后的结果,作为面向对象设计的模型,通常用于展示被设计系统的逻辑模型(业务逻辑如何设计),物理模型(系统如何划分,层次如何划分,如何部署……),静态模型(组成系统的元素:类,接口)和动态模型(对象的调用……)。将OOA分析的结果作进一步的规范化整理,以便能够被OOP直接接受。

概念可能比较生硬,那么说的直白点,设计阶段的任务就是:

按照面向对象的方式将系统分解成不同的模块化,或者系统再次划分为子系统,直到划分到可设计的最小粒度为止【垂直分块,水平分层】。
使用不同的表示方法来展示被设计系统的逻辑模型(业务逻辑如何设计),物理模型(系统如何划分,层次如何划分,如何部署……),静态模型(组成系统的元素:类,接口)和动态模型(对象的调用……)【常用的表示法手段:UML各种图形】。 [5]

[5] 里面还比较了OOA(抽象出类)和面向过程分析(找出步骤,用函数顺序实现),OOD(主要是正确有效的构造出复杂系统的抽象结构,将面向对象分析后的结果,作为面向对象设计的模型)和面向过程设计(将POA分析后的结果封装成JAVA对应的方法即可,然后在业务层中按照顺序调用接口。将领域对象(人民币)去掉行为,只保留属性即可,用于数据传输。以数据流向为主要导向。)的区别。很有意思。

2.老师PPT

1)Dog door
* 需求(requirements):是什么(要开发一个软件…),是谁提供的(利益相关者:用户,软件开发者,技术提供者等等)
* 具体的问题描述
A requirement is a feature that your system must have in order to satisfy the customer
A requirement is something your system must do.
A Use Case is a complete sequence of steps that provides value to someone/Something your system must do/Initiated by an Actor (someone or something not part of your system)
* Solving big problems usually involves solving the small problems first and then “gluing” the solutions together.
* Software architecture is the organizational structure of a system, including its decomposition into parts, their connectivity, interaction mechanisms, and the guiding principles and decisions that you use in the design of a system.
* Architecture reduces risk!

1-1)
stakeholder: A person, group, or organization that is actively involved in a project, is affected by its outcome, or can influence its outcome.

The term stakeholder is used to refer to any person or group who will be affected by the system, directly or indirectly. Stakeholders include end-users who interact with the system and everyone else in an organisation that may be affected by its installation. Other system stakeholders may be engineers who are developing or maintaining related systems, business managers, domain experts, and trade union representatives. [4]
这个解释很酷,利益相关者是指任何直接或间接被系统影响的人。利益相关者包括终端用户,everyone else,engineers(开发,维护),业务经理,领域专家,工会代表。

参考文献

[1] Object-oriented analysis and design. https://en.wikipedia.org/wiki/Object-oriented_analysis_and_design
[2] Unified Process. https://en.wikipedia.org/wiki/Unified_Process
[3] 面向对象和面向过程的区别. https://zhidao.baidu.com/question/2089034.html
[4] Are developers a stakeholder in a system? https://softwareengineering.stackexchange.com/questions/36415/are-developers-a-stakeholder-in-a-system
[5] 面试经典问题,谈谈你对OOA,OOD,OOP的理解. https://lovojava.github.io/2017/06/19/20170619/

猜你喜欢

转载自blog.csdn.net/weixin_39278265/article/details/80843267