`
buliedian
  • 浏览: 1186882 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

面向对象核心思想

阅读更多

面向对象核心思想

摘自:《Object-Oriented Software Construction 》BY Bertrand Meyer
刘建文略译(http://blog.csdn.net/keminlau

Born in the ice-blue waters of the festooned(以花彩装饰) Norwegian(挪威的) coast; amplified(放大) (by an aberration of world currents, for which marine geographers have yet to find a suitable explanation) along the much grayer range of the Californian Pacific; viewed by some as a typhoon(台风), by some as a tsunami海啸, and by some as a storm in a teacup — a tidal(潮汐的) wave is hitting the shores(岸, 滨) of the computing world.

对象技术诞生于挪威,成长于美国西海岸,有如狂风海啸席卷整个计算机世界。

“Object-oriented” is the latest in term, complementing and in many cases replacing “structured” as the high-tech version of “good”. As is inevitable(不可避免的; 必然的 ) in such a case, the term is used by different people with different meanings; just as inevitable is the well-known three-step sequence of reactions that meets the introduction of a new methodological principle: (1) “it's trivial”; (2) “it cannot work”; (3) “that's how I did it all along anyway”. (The order may vary.)

“面向对象”已经替代“结构化”成为最时尚的计算术语。“面向对象”也像其它 方法论 一样不可避免地受到人们的各种质疑。

Let us have this clear right away, lest(以免, 免得) the reader think the author takes a half-hearted approach to his topic: I do not see the object-oriented method as a mere(仅仅) fad(时尚); I think it is not trivial (although I shall strive(努力, 奋斗,) to make it as limpid(清澈的, 静止的,) as I can); I know it works; and I believe it is not only different from but even, to a certain extent, incompatible with the techniques that most people still use today — including some of the principles taught in many software engineering textbooks. I further believe that object technology holds the potential for fundamental changes in the software industry, and that it is here to stay.

Finally, I hope that as the reader progresses through these pages, he will share some of my excitement about this promising(有希望的,) avenue(大街, 途径, ) to software analysis, design and implementation.

我个人认为面向对象方法并不仅仅是一种时尚!不认为它是微不足道的。我了解它的原理,也认为它不仅仅与现存技术是量方面的不同,甚至是质的方面的不相容。从而我觉得对象技术是改变软件工业目前面貌的重要的根本的技术!对象方法是软件分析、设计和实现的有效途经。

“Avenue to software analysis, design and implementation”. To present the object-oriented method, this books resolutely takes the viewpoint of software engineering — of the methods, tools and techniques for developing quality software in production environments. This is not the only possible perspective, as there has also been interest in applying object-oriented principles to such areas as exploratory(探险的; 探测的) programming and artificial intelligence. Although the presentation does not exclude these applications, they are not its main emphasis. Our principal goal in this discussion is to study how practicing software developers, in industrial as well as academic environments, can use object technology to improve (in some cases dramatically) the quality of the software they produce.

对象方法是软件分析、设计和实现的有效途经。为了展示面向对象技术,本书从软件工程 的角度分析它。包括工程环境中用以开发高质量软件的各种方法、工具和技术。研究面向对象方法不仅可以从软件工程的角度,还可以从编程理论和人工智能理解的 角度,但本书的重点不是它们,所以不过过多的涉及这两方面的内容。我们的目标是软件实践者,包括工业和学术环境中的,如何使用对象技术提高(有时甚至是显 注的)软件的开发质量。(KEMIN:这里有个疑问,要保证软件的质量,那什么才是软件质量,怎么评价和度量?)

Structure, reliability, epistemology and classification

Object technology is at its core the combination of four ideas: a structuring method, a reliability discipline, an epistemological principle and a classification technique.

结构性、可靠性、认识论和分类法

对象技术的核心由四大思想组合而成:结构化方法、可靠性约束、认识论法则和分类法技术。

The structuring method applies to software decomposition and reuse. Software systems perform certain actions on objects of certain types; to obtain flexible and reusable systems, it is better to base their structure on the object types than on the actions. The resulting concept is a remarkably(非常地, 显著地,) powerful and versatile(通用的, 多才多艺的) mechanism called the class, which in object-oriented software construction serves as the basis for both the modular structure and the type system.

结构化方法 应用于软件分解与重用。软件系统一般都是根据特定的类型的对象执行相应的操作的,为了构造一个灵活的可重用的系统,系统的结构基于对象类型比基于计算操作来得有效。这一结论催生了类(class)的概念。类(class)是面向对象软件构造中模块结构和类型系统的基础。

The reliability discipline is a radical approach to the problem of building software that does what it is supposed to do. The idea is to treat any system as a collection of components which collaborate the way successful businesses do: by adhering(紧粘, 粘附; 坚持) to contracts defining explicitly the obligations(义务, 债务, 职责 ) and benefits incumbent(凭依的, 负有义务的) on each party.

可靠性约束 是用于解决构造指定功能软件及组件时面临的问题的基本方法。各取所需,各尽所能,这个思想的要义是,系统作业是由一组互相独立的组件相互协作:各部分有明文的职责和功能约定的。

The epistemological principle addresses the question of how we should describe the classes. In object technology, the objects described by a class are only defined by what we can do with them: operations (also known as features) and formal properties of these operations (the contracts). This idea is formally expressed by the theory of abstract data types , covered in detail in a chapter of this book. It has far-reaching implications(含意, 暗示 ), some going beyond software, and explains why we must not stop at the naïve concept of “object” borrowed from the ordinary meaning of that word. The tradition of information systems modeling usually assumes an “external reality” that predates( 在日期上早于) any program using it; for the object-oriented developer, such a notion is meaningless, as the reality does not exist independently of what you want to do with it. (More precisely whether it exists or not is an irrelevant question, as we only know what we can use, and what we know of something is defined entirely by how we can use it.)

认识论原理 定位于问题:我们应如何描述类(classes)。在对象技术里,用类(classes)描述的对象只定义了我们用对象能干些什么(包括对象功能操作和这些操作的形式属性[约定])。这个思想就是 抽象数据类型 理论。有人提出为什么不还原类(classes)在现实中的样子,就像数据库建模所使用的外部现实( external reality) 一般。在面向对象技术里不存在这样的问题,因为我们只关心能使用什么和需要使用什么就够 了。
KEMIN:b. 人的认知特点真有意思,中文比英文更亲切更易读,有想过为什么吗?面向对象比面向过程的程序设计方法更有效,又知道为什么吗?后一个问题里还有一个问题, 软件开发构造竟然与人的认知特点有联系!看看面向对象的定义:从现实世界中客观存在的事物(即对象)出发来构造软件系统,并在系统构造中 尽可能运用人类的自然思维方式 ,强调直接以问题域(现实世界)中的事物为中心来思考问题,认识问题。

The classification technique follows from the observation(观察; 观测;) that systematic intellectual work in general and scientific reasoning in particular require devising(设计; 图谋) taxonomies(分类法, 分类学) for the domains being studied. Software is no exception, and the object-oriented method relies heavily on a classification discipline known as inheritance.

我们对事物的认知是来自观察,并进行简单分类的,但是要深入研究某领域的事物而必须制定特定的分类法,以便进行科学推理。软件领域也不例外,而且面向对象方法更是严格基于分类法构造软件的,它的表现就是 继承 特性。

Simple but powerful

The four concepts of class, contract, abstract data type and inheritance immediately raise a number of questions. How do we find and describe classes? How should our programs manipulate classes and the corresponding objects (the instances of these classes)? What are the possible relations between classes? How can we capitalize on the commonalities(公共; 平民) that may exist between various classes? How do these ideas relate to such key software engineering concerns as extendibility, ease of use and efficiency?

简单却强悍

以上对象技术的四大思想引申出一大堆的问题:

  • 怎么确定系统使用的类?
  • 如何给这些类和对象分配角色和功能?
  • 类与类之间有哪些可能的关系?
  • 如何权衡两类间的功能大小(FIXME)
  • 这些思想又与软件工程最关心的问题,如可扩展性、易用性和开发效率有着怎样的关系呢?

Answers to these questions rely on a small but powerful array of techniques for producing reusable, extendible and reliable software: polymorphism and dynamic binding; a new view of types and type checking; genericity, constrained and unconstrained; information hiding; assertions; safe exception handling; automatic garbage collection. Efficient implementation techniques have been developed which permit applying these ideas successfully to both small and large projects under the tight constraints of commercial software development. Object-oriented techniques have also had a considerable impact on user interfaces and development environments, making it possible to produce much better interactive systems than was possible before. All these important ideas will be studied in detail, so as to equip the reader with tools that are immediately applicable to a wide range of problems.

这些问题的答案有赖于一系列简单却强悍的技术,它们保证了开发出可重用、可扩展和可靠的软件系统:

  • 多态和动态绑定;
  • 现代的类型概念及类型检查;
  • 泛型,约束与非约束;
  • 信息隐藏;
  • 断言(Assertion:An expression which, if false, indicates an error . Assertions are used for debugging by catching can't happen errors.)
  • 安全异常处理
  • 自动垃圾回收

Organization of the text
In the pages that follow we will review the methods and techniques of object-oriented software construction. The presentation has been divided into six parts.
Part A is an introduction and overview. It starts by exploring the fundamental issue of software quality and continues with a brief survey of the method's main technical characteristics. This part is almost a little book by itself, providing a first view of the object-oriented approach for hurried readers.

Part B is not hurried. Entitled “The road to object orientation”, it takes the time to describe the methodological concerns that lead to the central O-O concepts. Its focus is on modularity: what it takes to devise satisfactory structures for “in-the-large” system construction. It ends with a presentation of abstract data types, the mathematical basis for object technology. The mathematics involved is elementary, and less mathematically inclined readers may content themselves with the basic ideas, but the presentation provides the theoretical background that you will need for a full understanding of O-O principles and issues.

Part C is the technical core of the book. It presents, one by one, the central technical components of the method: classes; objects and the associated run-time model; memory management issues; genericity and typing; design by contract, assertions, exceptions; inheritance, the associated concepts of polymorphism and dynamic binding, and their many exciting applications.

Part D discusses methodology, with special emphasis on analysis and design
Through several in-depth case studies, it presents some fundamental design patterns, and
covers such central questions as how to find the classes, how to use inheritance properly
and how to design reusable libraries. It starts with a meta-level discussion of the
intellectual requirements on methodologists and other advice-givers; it concludes with a
review of the software process (the lifecycle model) for O-O development and a
discussion of how best to teach the method in both industry and universities.
Part E explores advanced topics: concurrency, distribution, client-server
development and the Internet; persistence, schema evolution and object-oriented
databases; the design of interactive systems with modern (“GUI”) graphical interfaces.


Part F is a review of how the ideas can be implemented, or in some cases emulated
in various languages and environments. This includes in particular a discussion of majo
object-oriented languages, focusing on Simula, Smalltalk, Objective-C, C++, Ada 95 and
Java, and an assessment of how to obtain some of the benefits of object orientation in such
non-O-O languages as Fortran, Cobol, Pascal, C and Ada.
Part G (doing it right) describes an environment which goes beyond these solution
and provides an integrated set of tools to support the ideas of the book.
As complementary reference material, an appendix shows some important reusabl
library classes discussed in the text, providing a model for the design of reusable software

b.忽然想到一个问题。如果光从“框架类库对零散基础的API函数进行语义包装”的功能看,C本身就具有这种包装功能,为什么要用C++呢?这显然说明了 面向对象的重点不在封装,而在继承和多态!那么MFC为实现一个应用框架又怎样的展现面向对象的这两项强大的机制呢?这问题很重要也很有意思!

分享到:
评论

相关推荐

    Java面向对象编程思想

    Java 的核心是面向对象编程.所有的java程序都是面向对象的。 以前总听老师说c语言是面向过程的,c++和java是面向对象的,这些糊涂老师却从来不说明何为面向过程,何为面向对象,搞得我一直对此稀里糊涂。 最近看了...

    在“魔兽争霸”游戏中学习面向对象的思想

    面向对象思想是学习java, .net等计算机语言的核心思想,在本人学习的过程中,本人直到最近对面向对象思想有了一个大突破后才发现原来在玩 “魔兽争霸”这个游戏的过程中就已经包含了深刻的面向对象的思想,现在根据...

    java面向对象核心思维导图

    特别详细的一个java面向对象核心的一个导图,分别详细介绍了对象和类、继承、封装、抽象类借口的思想以及需要注意的事项

    Week15_第7讲_面向对象核心技术.pdf

    面向对象核心技术 将对象的属性和行为封装起来,而将对象的属性和行为封装起来的载体就是类,类通常对客户隐藏其实现细节,这就是封装的思想。

    面向对象的需求分析方法

    面向对象的需求分析方法的核心是利用面向对象的概念和方法为软件需求建造模型。它包含面向对象风格的图形语言机制和用于指导需求分析的面向对象方法学。  面向对象的思想最初起源于 20世纪 60年代中期的仿真程序...

    CHJava核心思想面向对象学习教案.pptx

    CHJava核心思想面向对象学习教案.pptx

    CHJava核心思想面向对象PPT课件.pptx

    CHJava核心思想面向对象PPT课件.pptx

    JavaScript面向对象编程指南.pdf

    JavaScript作为一门浏览器语言的核心思想;面向对象编程的基础知识及其在JavaScript中的运用;数据类型、操作符以及流程控制语句;函数、闭包、对象和原型等概念,以代码重用为目的的继承模式;BOM、DOM、浏览器事件...

    JAVA面向对象编程_孙卫琴2.pdf

    本章首先简要介绍了结构化的软件开发过程,然后介绍面向对象的软件开发过程,对面向对象的一些核心思想和概念做了阐述。本章列举了不少形象的例子,来帮助读者理解面向对象的开发思想,并且以一个画板Panel软件系统...

    JavaScript面向对象编程指南

    《JavaScript面向对象编程指南》内容包括:JavaScript作为一门浏览器语言的核心思想;面向对象编程的基础知识及其在JavaScript中的运用;数据类型、操作符以及流程控制语句;函数、闭包、对象和原型等概念,以代码...

    CHJava核心思想面向对象PPT学习教案.pptx

    CHJava核心思想面向对象PPT学习教案.pptx

    javascript面向对象编程

    JavaScript作为一门浏览器语言的核心思想;面向对象编程的基础知识及其在JavaScript中的运用;数据类型、操作符以及流程控制语句;函数、闭包、对象和原型等概念,以代码重用为目的的继承模式;BOM、DOM、浏览器事件...

    软件设计原则-面向对象设计七大原则.zip

    面向对象和C语言完全不是一种思考问题的方式,面向对象是种哲学思想,只有明白了其核心思想,才能以不变应万变 只有吃透面向对象的七大设计原则,比如:依赖倒置原则,迪米特法则等,把它们烂熟于心,才能作到看什么书都一样...

    Java面向对象编程指南

    权威的Java面向对象权威指南,比较面向过程的思想和面向对象的思想: 面向过程的思想:由过程、步骤、函数组成,以过程为核心; 面向对象的思想:以对象为中心,先开发类,得到对象,通过对象之间相互通信实现功能。...

    Java核心及基础应用-Java 面向对象思想及核心.ppt

    Java核心及基础应用-Java 面向对象思想及核心.ppt

    用面向对象设计的方法,设计一个圆的类

    用面向对象设计的方法,设计一个圆的类,包括计算圆的直径、圆的周长和圆的面积的方法。 【问题描述】 用面向对象设计的方法,设计一个圆的类,包括计算圆的直径、圆的周长和圆的面积的方法。 【基本要求】 采用...

    面向对象的分析与设计_第二章_需求概述

    IBM Software Institute 需求概述的内容 简要介绍 核心概念 用例模型 术语表 补充说明 检查点列举 使用UML进行面向对象分析与设计 2004 IBM Software Institute

    Java面向对象编程课后习题答案及源代码

    看清Java万花筒的本质,从复杂的表象中寻找普遍的规律,深刻理解Java的核心思想。 紧密结合实际,运用典型实例,循序渐进,行动详细讲解Java面向对象的编程思想、编程语法和设计模式。 总结优化Java编程的各种宝贵...

Global site tag (gtag.js) - Google Analytics