面向对象软件构造(第2版)-第5章 接近对象技术 (下)

5.3 OBJECT-BASED DECOMPOSITION

5.3 基于对象的分解

 

The case for using objects (or more precisely, as seen below, object types) as the key to system modularization is based on the quality aims defined in chapter 1, in particular extendibility, reusability and compatibility.

使用对象(或下所示,更精确地说是对象类型(object types))作为系统模块化的关键,这建立在第1章中所定义的品质目标之上,尤其是扩充性,复用性和兼容性.

 

The plea for using objects will be fairly short, since the case has already been made at least in part: many of the arguments against top-down, function-based design reappear naturally as evidence in favor of bottom-up, object-based design.

由于这种情况至少部份被建立了,所以使用对象的请求将会相当的快: 许多不支持由上而下的,基于函数设计的理由会很自然地重现了支持由下而上的,基于对象设计的迹象.

 

This evidence should not, however, lead us to dismiss the functions entirely. As noted at the beginning of this chapter, no approach to software construction can be complete unless it accounts for both the function and object parts. So we will need to retain a clear role for functions in the object-oriented method, even if they must submit to the objects in the resulting system architectures. The notion of abstract data type will provide us with a definition of objects which reserves a proper place for the functions.

然而,这种现象不应该让我们完全地放弃函数.如本章开始所述,对于软件构造来说,没有什么方法是完善的,除非它解决了函数和对象两者之间的关系.因此我们需要在面向对象的方法中保留一个明确的角色给函数,即使它们必须服从在目标系统架构中的对象.抽象数据类型的观念将会给我们提供一个对象的定义,这个对象为函数保留了一个适当的位置.

 

Extendibility

扩充性

 

If the functions of a system, as discussed above, tend to change often over the system’s life, can we find a more stable characterization of its essential properties, so as to guide our choice of modules and meet the goal of continuity?

如上所述,如果一个系统的函数试图时常改变系统的活动,我们能找到其本质属性中的一个更稳定的特征,以指导我们对模块的选择并符合连续性的目标吗?

 

The types of objects manipulated by the system are more promising candidates. Whatever happens to the payroll processing system used earlier as an example, it likely will still manipulate objects representing employees, salary scales, company regulations, hours worked, pay checks. Whatever happens to a compiler or other language processing tool, it likely will still manipulate source texts, token sequences, parse trees, abstract syntax trees, target code. Whatever happens to a finite element system, it likely will still manipulate matrices, finite elements and grids.

被系统操纵的对象类型是较有希望的备选方案.无论在先前所用的薪资处理系统例子上发生什么变化,它或许仍旧将操纵对象来描述雇员,薪水标准,公司规章,工时,薪资账单.无论在一个编译器或其它语言的处理工具上发生什么变化,它或许仍旧操纵着源代码,令牌顺序,剖析树,抽象语法树,目标码.无论在一个有限元系统上发生了什么变化,它或许仍然操纵着矩阵(matrices),有限元(finite elements)和网格.

 

This argument is based on pragmatic observation, not on a proof that object types are more stable than functions. But experience seems to support it overwhelmingly.

这个论据以实际的调查为基础,并没有证明对象类型比函数更稳定.但是经验却压倒性地支持了这个观点.

 

The argument only holds if we take a high-level enough view of objects. If we understood objects in terms of their physical representations, we would not be much better off than with functions — as a matter of fact probably worse, since a top-down functional decomposition at least encourages abstraction. So the question of finding a suitably abstract description of objects is crucial; it will occupy all of the next chapter.

如果我们以足够高的层次来观察对象,这个观点只是很合理.如果我们按照它们的实际表现来理解对象,我们并不能得到比函数更好的结果-事实上或许更糟,因为一个由上而下的函数分解至少还鼓励抽象化.因此,至关重要的问题是发现一个对象的合适的抽象描述;下一章的整个篇幅都会来讨论它.

 

Reusability

复用性

 

The discussion of reusability pointed out that a routine (a unit of functional decomposition) was usually not sufficient as a unit of reusability.

复用性的讨论指出一个例程(一个函数分解的单元)作为一个复用性单元通常是不充份的.

 

The presentation used a typical example: table searching. Starting with a seemingly natural candidate for reuse, a searching routine, it noted that we cannot easily reuse such a routine separately from the other operations that apply to a table, such as creation, insertion and deletion; hence the idea that a satisfactory reusable module for such a problem should be a collection of such operations. But if we try to understand the conceptual thread that unites all these operations, we find the type of objects to which they apply — tables.

表示法曾用了一个典型的例子: 表查询. 一个查询例程,以一个表面上的潜在需求开始,注意到我们不能够简单地复用这样的一个例程,把它从应用于表的运算,如创建,插入和删除这样的运算中分开;因此,对这样的一个问题,一个能满足复用模块的想法应该是这些运算的一个集合(collection). 但是如果我们试着其理解概念上的思路,即把所有的这些运算联合起来,那么我们就能找到应用的对象类型-表.

 

Such examples suggest that object types, fully equipped with the associated operations, will provide stable units of reuse.

这样的例子建议,完全具备相关运算的对象类型将会提供稳定的复用单元.

 

Compatibility

兼容性

 

Another software quality factor, compatibility, was defined as the ease with which software products (for this discussion, modules) can be combined with each other.

另一个软件品性因素,兼容性,被定义为对任一软件产品(在这个讨论中是指模块)易于彼此连接.

 

It is difficult to combine actions if the data structures they access are not designed for that purpose. Why not instead try to combine entire data structures?

如果它们访问的数据结构并不是为上述目的而设计的,那么联合这些动作是很困难的.为什么不去试着连接整个的数据结构?

 

5.4 OBJECT-ORIENTED SOFTWARE CONSTRUCTION

5.4 面向对象软件构造

 

We have by now accumulated enough background to consider a tentative definition of object-oriented software construction. This will only be a first attempt; a more concrete definition will follow from the discussion of abstract data types in the next chapter.

此时,我们已经积累了充足的背景知识来试着考虑面向对象软件构造的定义.这将只是一种最初的尝试;在下一章的抽象数据类型的讨论中,我们会得出一个更精确的定义.

 

 

Object-oriented software construction (definition 1)

Object-oriented software construction is the software development method which bases the architecture of any software system on modules deduced from the types of objects it manipulates (rather than the function or functions that the system is intended to ensure).

面向对象软件构造是一种软件开发方法,使用此方法的任何软件系统的架构都是基于从自己操纵的对象类型(而不是函数或系统规定好的的函数)中所推导出来的模块.

 

 

An informal characterization of this approach may serve as a motto for the object-oriented designer:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

此方式的一个非正式的描述被面向对象的设计者奉为箴言:

OBJECT MOTTO

Ask not first what the system does:

Ask what it does it to!

不要先问系统做什么,而问系统如何去做它!

 

 

 

 

 

 

 

 

To get a working implementation, you will of course, sooner or later, have to find out what it does. Hence the word first. Better later than sooner, says object-oriented wisdom. In this approach, the choice of main function is one of the very last steps to be taken in the process of system construction.

当然,得到一个能运行的实现,您终究会发现它所做的目的.单词first由此而来.迟来比早来更好,这说明了面向对象的聪明之处.在这个方法中,主函数的选择是系统结构过程中所采取的最终步骤之一.

 

The developers will stay away, as long as possible, from the need to describe and implement the topmost function of the system. Instead, they will analyze the types of objects of the system. System design will progress through the successive improvements of their understanding of these object classes. It is a bottom-up process of building robust and extendible solutions to parts of the problem, and combining them into more and more powerful assemblies — until the final assembly which yields a solution of the original problem but, everyone hopes, is not the only possible one: the same components, assembled differently and probably combined with others, should be general enough to yield as a byproduct, if you have applied the method well and enjoyed your share of good luck, solutions to future problems as well.

可能的话,开发者并不会参与从需求到描述和实现系统的顶端函数的过程.他们更可能的是去分析系统的对象类型.通过他们对这些对象类型的理解的持续的改进,系统设计将不断地前进.对局部的问题构建健壮和可扩充的解决方案,这是一个由下而上的过程,并且把它们合并进越来越强大的整合中-直到产生最初问题的解决方案的最终整合,但是每个人所希望的不仅仅如此:如果您已经把此方法应用得很好并且幸运的是解决方案也能应对将来的问题,那么这些组件,被不同地组合同时联合其它的组件,将能足够通用以产生另外的产品.

 

For many software people this change in viewpoint is as much of a shock as may have been for others, in an earlier time, the idea of the earth orbiting around the sun rather than the reverse. It is also contrary to much of the established software engineering wisdom, which tends to present system construction as the fulfillment of a system’s function as expressed in a narrow, binding requirements document. Yet this simple idea — look at the data first, forget the immediate purpose of the system — may hold the key to reusability and extendibility.

对于许多软件工程师来说,这个观点的改变所产生的震动就像先前地球围绕太阳转的思想对于传统想法的冲击一样.它也和以往所建立的软件工程的知识相反,在一个有限的约束性的需求文档中,旧观点倾向于用一个系统函数的实现来表现系统构造.这个简单的思维-先看数据,忽略系统的直接目的-也可以掌握复用性和扩充性的关键。

 

5.5 ISSUES

5.5 议题

 

The above definition provides a starting point to discuss the object-oriented method. But besides providing components of the answer it also raises many new questions, such as:

• How to find the relevant object types.

• How to describe the object types.

• How to describe the relations and commonalities between object types.

• How to use object types to structure software.

上述的定义对讨论面向对象方法提供了一个开端.但是除了提供对应的组件之外,它也引发了许多新的问题:

·        该如何寻找有关的对象类型.

·        该如何描述对象类型.

·        该如何描述在对象类型之间的关系和共通性.

·        该如何使用对象类型构建软件.

 

The rest of this book will address these issues. Let us preview a few answers.

本书的其余部分将会致力于这些议题.让我们先了解部分答案.

 

Finding the object types

寻找对象类型

 

The question “how shall we find the objects?” can seem formidable at first. A later chapter will examine it in some detail (in its more accurate version, which deals with object types rather than individual objects) but it is useful here to dispel some of the possible fears. The question does not necessarily occupy much of the time of experienced O-O developers, thanks in part to the availability of three sources of answers:

"我们将如何寻找对象?"这个问题起先看上去非常令人生畏.稍后的章节将会在一些细节上(在更精确的版本中,它处理对象类型而不是单独的对象)加以阐述但是这里先消除一些可能的疑惑.这个问题不会占据富有经验的OO开发者的太多时间,部份地原因是答案的三个来源的有效性:

 

• Many objects are there just for the picking. They directly model objects of the physical reality to which the software applies. One of the particular strengths of object technology is indeed its power as a modeling tool, using software object types (classes) to model physical object types, and the method’s inter-object-type relations (client, inheritance) to model the relations that exist between physical object types, such as aggregation and specialization. It does not take a treatise on object-oriented analysis to convince a software developer that a call monitoring system, in a telecommunications application, will have a class CALL and a class LINE, or that a document processing system will have a class DOCUMENT, a class PARAGRAPH and a class FONT.

在那里许多对象仅仅是为了选择.它们直接地模拟软件所应用的实际的对象.对象技术的特别力量之一是作为一个建模工具的真正能力,就是使用软件对象类型()去模拟实际的对象类型,使用函数的内部对象类型关系(客户端,继承)去模拟实际的对象类型之间存在的关系,像是集合(aggregation)特殊化(specialization)之间的关系.在一个通讯应用程序中的一个呼叫监听系统将会有一个CALL类和一个LINE,或一个文件处理系统将会有一个DOCUMENT类,一个PARAGRAPH类和一个FONT,这并不需要用面向对象分析上的专题论文才能使软件开发者相信.

 

• A source of object types is reuse: classes previously developed by others. This technique, although not always prominent in the O-O analysis literature, is often among the most useful in practice. We should resist the impulse to invent something if the problem has already been solved satisfactorily by others.

对象类型的一个来源是复用:之前的类都是其他人开发的.虽然这并不总是在OO分析的文献中被强调,但是这种技术在实践中往往是最有用的.如果问题已经圆满地被其他人解决了,我们应该忍得住重新开发的冲动.

 

• Finally, experience and imitation also play a role. As you become familiar with successful object-oriented designs and design patterns (such as some of those described in this book and the rest of the O-O literature), even those which are not directly reusable in your particular application, you will be able to gain inspiration from these earlier efforts.

最后,经验和模仿也起着作用.当您熟悉了成功运用面向对象设计和设计模式(本书会介绍一部分,其余的会在OO文献中找到),甚至在您的个别的应用程序中还不可以直接复用的时候,你就能够从这些早期地努力中获得灵感.

 

We will be in a much better position to understand these object-finding techniques and others once we have gained a better technical insight into the software notion of object — not to be confused with the everyday meaning of the word.

一旦我们获得一个更佳的技术来洞察软件的对象观念-不要被这些词组的平凡意义所困扰,我们将能更好的理解这些探索对象和与之相关的技术.

 

Describing types and objects

描述类型对象

 

A question of more immediate concern, assuming we know how to obtain the proper object types to serve as a basis for modularizing our systems, is how to describe these types and their objects.

一个更值得注意的问题是,假定我们知道该如何获得适当的对象类型作为我们的系统模块化的基础,该如何描述这些类型和它们的对象.

 

Two criteria must guide us in answering this question:

要回答这个问题,我们必须遵循二个标准:

 

• The need to provide representation-independent descriptions, for fear of losing (as noted) the principal benefit of top-down functional design: abstraction.

需要提供表示法独立的描述,这是担心失去由上而下函数设计的主要优点:抽象化.

 

• The need to re-insert the functions, giving them their proper place in software architectures whose decomposition is primarily based on the analysis of object types since (as also noted) we must in the end accommodate both aspects of the object-function duality.

需要重新插入(re-insert)函数,这是在主要地以对象类型分析为分解基础的软件架构中,提供给它们适当的位置,因为最终我们必须调节对象-函数二元性双方.

 

The next chapter develops an object description technique achieving these goals.

下一章我们将开发一个对象描述的技术用来完成这些目标.

 

Describing the relations and structuring software

描述关系并构建软件

 

Another question is what kind of relation we should permit between object types; since the modules will be based on object types, the answer also determines the structuring techniques that will be available to make up software systems from components.

另一个问题是我们应该在对象类型之间允许什么样的关系;由于模块以对象类型为基础,答案也决定了其构成技术,这种技术能有效的从组件中组合软件系统.

 

In the purest form of object technology, only two relations exist: client and inheritance. They correspond to different kinds of possible dependency between two object types A and B:

在最纯粹的对象技术形式中,只有二个关系存在: 客户端和继承.它们符合在二种对象类型AB之间的可能存在的不同种类的相关性:

 

B is a client of A if every object of type B may contain information about one or more objects of type A.

如果每个B类型的对象可以包含一个或更多的A类型对象的信息,那么B就是A的客户端.

 

B is an heir of A if B denotes a specialized version of A.

如果B表示为一个特殊化的A版本,那么B就是A的一个继承.

 

Some widely used approaches to analysis, in particular information modeling approaches such as entity-relationship modeling, have introduced rich sets of relations to describe the many possible connections that may exist between the element of a system. To people used to such approaches, having to do with just two kinds of relation often seems restrictive at first. But this impression is not necessarily justified:

一些被广泛使用的分析方法,特别是信息建模方法如实体-关系建模(entity-relationship modeling),已经介绍了大量的相关机制来描述许多可能存在于系统元素之间的关联.在人们使用这样的方法之前,不得不首先处理二种看上去受限制的关系类型.但是这种印象不必证实:

 

• The client relation is broad enough to cover many different forms of dependency. Examples include what is often called aggregation (the presence in every object of type B of a subobject of type A), reference dependency, and generic dependency.

客户端的关系应足够宽广以包括许多不同形式的关联。例子包括有聚合(A类型的一个子对象,B类型的每个对象的集合),引用关联和泛型关联

 

• The inheritance relation covers specialization in its many different forms.

继承关系包括了其许多不同形式的特殊化。

 

• Many properties of dependencies will be expressed in a more general form through other techniques. For example, to describe a 1-to-n dependency (every object of type B is connected to at least one and at most n objects of type A) we will express that B is a client of A, and include a class invariant specifying the exact nature of the client relation. The class invariant, being expressed in the language of logic, covers many more cases than the finite set of primitive relations offered by entity-relationship modeling or similar approaches.

关联的许多属性通过其它的技术将会以一种更通用的形式表达出来.举例来说,要描述一个1-to-n(一对多)关联(B类型的每个对象至少被连接到一个或最多nA类型的对象上)我们将表示B是一个A的客户端,同时包括一个类不变式(class invariant)叙述客户端关系的精确类型。相比实体-关系建模或相似的方法提供的原始关系的有限集合,在逻辑语言中表达的类不变式包含了更多的情况。

 

5.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER

5.6 摘要

 

• Computation involves three kinds of ingredient: processors (or threads of control), actions (or functions), and data (or objects).

计算包括三种成分: 处理器(或控制线程),动作(或函数)和数据(或对象).

 

• A system’s architecture may be obtained from the functions or from the object types.

一个系统的架构可以从函数上或从对象类型上获得.

 

• A description based on object types tends to provide better stability over time and better reusability than one based on an analysis of the system’s functions.

基于对象类型的描述比基于系统函数分析的描述能提供更好的超时稳定性和更好的复用性.

 

• It is usually artificial to view a system as consisting of just one function. A realistic system usually has more than one “top” and is better described as providing a set of services.

通常人为的把一个系统看成只有一个函数所组成.一个现实的系统通常有超过一个的顶端,而且会提供一组服务来更好地描述此系统.

 

• It is preferable not to pay too much attention to ordering constraints during the early stages of system analysis and design. Many temporal constraints can be described more abstractly as logical constraints.

在系统分析和设计的早期阶段,较好的方法是不要对次序约束给予太多的关注.许多时间约束可能被更抽象的描述成逻辑限制。

 

• Top-down functional design is not appropriate for the long-term view of software systems, which involves change and reuse.

从一个包括变化和复用的软件系统的长期观点来看,由上而下的函数设计并不适宜.

 

• Object-oriented software construction bases the structure of systems on the types of objects they manipulate.

面向对象的软件构造把系统结构建立在其操纵的对象类型之上.

 

• In object-oriented design, the primary design issue is not what the system does, but what types of objects it does it to. The design process defers to the last steps the decision as to what is the topmost function, if any, of the system.

在面向对象的设计中,主要的设计议题不是系统做什么,而是系统有什么样的对象类型去做.如有可能,设计过程推迟到最后的阶段去决定什么是系统的最高点函数.

 

• To satisfy the requirements of extendibility and reusability, object-oriented software construction needs to deduce the architecture from sufficiently abstract descriptions of objects.

为了要满足扩充性和复用性的需求,面向对象软件构造需要从充份的对象抽象描述中推论出架构.

 

• Two kinds of relation may exist between object types: client and inheritance.

二种类型的关系可以在对象类型之间存在: 客户端和继承.

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Contents Preface v Foreword to the second edition xiii About the accompanying CD-ROM xiv On the bibliography, Internet sources and exercises xv Contents xvii PART A: THE ISSUES 1 Chapter 1: Software quality 3 1.1 EXTERNAL AND INTERNAL FACTORS 3 1.2 A REVIEW OF EXTERNAL FACTORS 4 1.3 ABOUT SOFTWARE MAINTENANCE 17 1.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 19 1.5 BIBLIOGRAPHICAL NOTES 19 Chapter 2: Criteria of object orientation 21 2.1 ON THE CRITERIA 21 2.2 METHOD AND LANGUAGE 22 2.3 IMPLEMENTATION AND ENVIRONMENT 31 2.4 LIBRARIES 33 2.5 FOR MORE SNEAK PREVIEW 34 2.6 BIBLIOGRAPHICAL NOTES AND OBJECT RESOURCES 34 PART B: THE ROAD TO OBJECT ORIENTATION 37 Chapter 3: Modularity 39 3.1 FIVE CRITERIA 40 3.2 FIVE RULES 46 3.3 FIVE PRINCIPLES 53 3.4 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 64 3.5 BIBLIOGRAPHICAL NOTES 64 EXERCISES 65CONTENTS xviii Chapter 4: Approaches to reusability 67 4.1 THE GOALS OF REUSABILITY 68 4.2 WHAT SHOULD WE REUSE? 70 4.3 REPETITION IN SOFTWARE DEVELOPMENT 74 4.4 NON-TECHNICAL OBSTACLES 74 4.5 THE TECHNICAL PROBLEM 81 4.6 FIVE REQUIREMENTS ON MODULE STRUCTURES 83 4.7 TRADITIONAL MODULAR STRUCTURES 89 4.8 OVERLOADING AND GENERICITY 93 4.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 98 4.10 BIBLIOGRAPHICAL NOTES 99 Chapter 5: Towards object technology 101 5.1 THE INGREDIENTS OF COMPUTATION 101 5.2 FUNCTIONAL DECOMPOSITION 103 5.3 OBJECT-BASED DECOMPOSITION 114 5.4 OBJECT-ORIENTED SOFTWARE CONSTRUCTION 116 5.5 ISSUES 117 5.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 119 5.7 BIBLIOGRAPHICAL NOTES 119 Chapter 6: Abstract data types 121 6.1 CRITERIA 122 6.2 IMPLEMENTATION VARIATIONS 122 6.3 TOWARDS AN ABSTRACT VIEW OF OBJECTS 126 6.4 FORMALIZING THE SPECIFICATION 129 6.5 FROM ABSTRACT DATA TYPES TO CLASSES 142 6.6 BEYOND SOFTWARE 147 6.7 SUPPLEMENTARY TOPICS 148 6.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 159 6.9 BIBLIOGRAPHICAL NOTES 160 EXERCISES 161 PART C: OBJECT-ORIENTED TECHNIQUES 163 Chapter 7: The static structure: classes 165 7.1 OBJECTS ARE NOT THE SUBJECT 165 7.2 AVOIDING THE STANDARD CONFUSION 166 7.3 THE ROLE OF CLASSES 169 7.4 A UNIFORM TYPE SYSTEM 171 7.5 A SIMPLE CLASS 172 7.6 BASIC CONVENTIONS 177CONTENTS xix 7.7 THE OBJECT-ORIENTED STYLE OF COMPUTATION 181 7.8 SELECTIVE EXPORTS AND INFORMATION HIDING 191 7.9 PUTTING EVERYTHING TOGETHER 194 7.10 DISCUSSION 203 7.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 213 7.12 BIBLIOGRAPHICAL NOTES 215 EXERCISES 216 Chapter 8: The run-time structure: objects 217 8.1 OBJECTS 218 8.2 OBJECTS AS A MODELING TOOL 228 8.3 MANIPULATING OBJECTS AND REFERENCES 231 8.4 CREATION PROCEDURES 236 8.5 MORE ON REFERENCES 240 8.6 OPERATIONS ON REFERENCES 242 8.7 COMPOSITE OBJECTS AND EXPANDED TYPES 254 8.8 ATTACHMENT: REFERENCE AND VALUE SEMANTICS 261 8.9 DEALING WITH REFERENCES: BENEFITS AND DANGERS 265 8.10 DISCUSSION 270 8.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 276 8.12 BIBLIOGRAPHICAL NOTES 277 EXERCISES 277 Chapter 9: Memory management 279 9.1 WHAT HAPPENS TO OBJECTS 279 9.2 THE CASUAL APPROACH 291 9.3 RECLAIMING MEMORY: THE ISSUES 293 9.4 PROGRAMMER-CONTROLLED DEALLOCATION 294 9.5 THE COMPONENT-LEVEL APPROACH 297 9.6 AUTOMATIC MEMORY MANAGEMENT 301 9.7 REFERENCE COUNTING 302 9.8 GARBAGE COLLECTION 304 9.9 PRACTICAL ISSUES OF GARBAGE COLLECTION 309 9.10 AN ENVIRONMENT WITH MEMORY MANAGEMENT 312 9.11 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 315 9.12 BIBLIOGRAPHICAL NOTES 315 EXERCISES 316 Chapter 10: Genericity 317 10.1 HORIZONTAL AND VERTICAL TYPE GENERALIZATION 317 10.2 THE NEED FOR TYPE PARAMETERIZATION 318 10.3 GENERIC CLASSES 320CONTENTS xx 10.4 ARRAYS 325 10.5 THE COST OF GENERICITY 328 10.6 DISCUSSION: NOT DONE YET 329 10.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 329 10.8 BIBLIOGRAPHICAL NOTES 330 EXERCISES 330 Chapter 11: Design by Contract: building reliable software 331 11.1 BASIC RELIABILITY MECHANISMS 332 11.2 ABOUT SOFTWARE CORRECTNESS 333 11.3 EXPRESSING A SPECIFICATION 334 11.4 INTRODUCING ASSERTIONS INTO SOFTWARE TEXTS 337 11.5 PRECONDITIONS AND POSTCONDITIONS 338 11.6 CONTRACTING FOR SOFTWARE RELIABILITY 341 11.7 WORKING WITH ASSERTIONS 348 11.8 CLASS INVARIANTS 363 11.9 WHEN IS A CLASS CORRECT? 369 11.10 THE ADT CONNECTION 373 11.11 AN ASSERTION INSTRUCTION 378 11.12 LOOP INVARIANTS AND VARIANTS 380 11.13 USING ASSERTIONS 389 11.14 DISCUSSION 398 11.15 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 406 11.16 BIBLIOGRAPHICAL NOTES 407 EXERCISES 408 POSTSCRIPT: THE ARIANE 5 FAILURE 410 Chapter 12: When the contract is broken: exception handling 411 12.1 BASIC CONCEPTS OF EXCEPTION HANDLING 411 12.2 HANDLING EXCEPTIONS 414 12.3 AN EXCEPTION MECHANISM 419 12.4 EXCEPTION HANDLING EXAMPLES 422 12.5 THE TASK OF A RESCUE CLAUSE 427 12.6 ADVANCED EXCEPTION HANDLING 431 12.7 DISCUSSION 435 12.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 437 12.9 BIBLIOGRAPHICAL NOTES 438 EXERCISES 438 Chapter 13: Supporting mechanisms 439 13.1 INTERFACING WITH NON-O-O SOFTWARE 439 13.2 ARGUMENT PASSING 444CONTENTS xxi 13.3 INSTRUCTIONS 447 13.4 EXPRESSIONS 452 13.5 STRINGS 456 13.6 INPUT AND OUTPUT 457 13.7 LEXICAL CONVENTIONS 457 13.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 458 EXERCISES 458 Chapter 14: Introduction to inheritance 459 14.1 POLYGONS AND RECTANGLES 460 14.2 POLYMORPHISM 467 14.3 TYPING FOR INHERITANCE 472 14.4 DYNAMIC BINDING 480 14.5 DEFERRED FEATURES AND CLASSES 482 14.6 REDECLARATION TECHNIQUES 491 14.7 THE MEANING OF INHERITANCE 494 14.8 THE ROLE OF DEFERRED CLASSES 500 14.9 DISCUSSION 507 14.10 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 516 14.11 BIBLIOGRAPHICAL NOTES 517 EXERCISES 517 Chapter 15: Multiple inheritance 519 15.1 EXAMPLES OF MULTIPLE INHERITANCE 519 15.2 FEATURE RENAMING 535 15.3 FLATTENING THE STRUCTURE 541 15.4 REPEATED INHERITANCE 543 15.5 DISCUSSION 563 15.6 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 566 15.7 BIBLIOGRAPHICAL NOTES 567 EXERCISES 567 Chapter 16: Inheritance techniques 569 16.1 INHERITANCE AND ASSERTIONS 569 16.2 THE GLOBAL INHERITANCE STRUCTURE 580 16.3 FROZEN FEATURES 583 16.4 CONSTRAINED GENERICITY 585 16.5 ASSIGNMENT ATTEMPT 591 16.6 TYPING AND REDECLARATION 595 16.7 ANCHORED DECLARATION 598 16.8 INHERITANCE AND INFORMATION HIDING 605 16.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 609CONTENTS xxii 16.10 BIBLIOGRAPHICAL NOTE 610 EXERCISES 610 Chapter 17: Typing 611 17.1 THE TYPING PROBLEM 611 17.2 STATIC TYPING: WHY AND HOW 615 17.3 COVARIANCE AND DESCENDANT HIDING 621 17.4 FIRST APPROACHES TO SYSTEM VALIDITY 628 17.5 RELYING ON ANCHORED TYPES 630 17.6 GLOBAL ANALYSIS 633 17.7 BEWARE OF POLYMORPHIC CATCALLS! 636 17.8 AN ASSESSMENT 639 17.9 THE PERFECT FIT 640 17.10 KEY CONCEPTS STUDIED IN THIS CHAPTER 641 17.11 BIBLIOGRAPHICAL NOTES 641 Chapter 18: Global objects and constants 643 18.1 CONSTANTS OF BASIC TYPES 643 18.2 USE OF CONSTANTS 645 18.3 CONSTANTS OF CLASS TYPES 646 18.4 APPLICATIONS OF ONCE ROUTINES 648 18.5 CONSTANTS OF STRING TYPE 653 18.6 UNIQUE VALUES 654 18.7 DISCUSSION 656 18.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 659 18.9 BIBLIOGRAPHICAL NOTES 660 EXERCISES 660 PART D: OBJECT-ORIENTED METHODOLOGY: APPLYING THE METHOD WELL 661 Chapter 19: On methodology 663 19.1 SOFTWARE METHODOLOGY: WHY AND WHAT 663 19.2 DEVISING GOOD RULES: ADVICE TO THE ADVISORS 664 19.3 ON USING METAPHORS 671 19.4 THE IMPORTANCE OF BEING HUMBLE 673 19.5 BIBLIOGRAPHICAL NOTES 674 EXERCISES 674 Chapter 20: Design pattern: multi-panel interactive systems 675 20.1 MULTI-PANEL SYSTEMS 675 20.2 A SIMPLE-MINDED ATTEMPT 677CONTENTS xxiii 20.3 A FUNCTIONAL, TOP-DOWN SOLUTION 678 20.4 A CRITIQUE OF THE SOLUTION 682 20.5 AN OBJECT-ORIENTED ARCHITECTURE 684 20.6 DISCUSSION 693 20.7 BIBLIOGRAPHICAL NOTE 694 Chapter 21: Inheritance case study: “undo” in an interactive system 695 21.1 PERSEVERARE DIABOLICUM 695 21.2 FINDING THE ABSTRACTIONS 699 21.3 MULTI-LEVEL UNDO-REDO 704 21.4 IMPLEMENTATION ASPECTS 707 21.5 A USER INTERFACE FOR UNDOING AND REDOING 711 21.6 DISCUSSION 712 21.7 BIBLIOGRAPHICAL NOTES 715 EXERCISES 715 Chapter 22: How to find the classes 719 22.1 STUDYING A REQUIREMENTS DOCUMENT 720 22.2 DANGER SIGNALS 726 22.3 GENERAL HEURISTICS FOR FINDING CLASSES 731 22.4 OTHER SOURCES OF CLASSES 735 22.5 REUSE 740 22.6 THE METHOD FOR OBTAINING CLASSES 741 22.7 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 743 22.8 BIBLIOGRAPHICAL NOTES 744 Chapter 23: Principles of class design 747 23.1 SIDE EFFECTS IN FUNCTIONS 748 23.2 HOW MANY ARGUMENTS FOR A FEATURE? 764 23.3 CLASS SIZE: THE SHOPPING LIST APPROACH 770 23.4 ACTIVE DATA STRUCTURES 774 23.5 SELECTIVE EXPORTS 796 23.6 DEALING WITH ABNORMAL CASES 797 23.7 CLASS EVOLUTION: THE OBSOLETE CLAUSE 802 23.8 DOCUMENTING A CLASS AND A SYSTEM 803 23.9 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 806 23.10 BIBLIOGRAPHICAL NOTES 806 EXERCISES 807CONTENTS xxiv Chapter 24: Using inheritance well 809 24.1 HOW NOT TO USE INHERITANCE 809 24.2 WOULD YOU RATHER BUY OR INHERIT? 812 24.3 AN APPLICATION: THE HANDLE TECHNIQUE 817 24.4 TAXOMANIA 820 24.5 USING INHERITANCE: A TAXONOMY OF TAXONOMY 822 24.6 ONE MECHANISM, OR MORE? 833 24.7 SUBTYPE INHERITANCE AND DESCENDANT HIDING 835 24.8 IMPLEMENTATION INHERITANCE 844 24.9 FACILITY INHERITANCE 847 24.10 MULTIPLE CRITERIA AND VIEW INHERITANCE 851 24.11 HOW TO DEVELOP INHERITANCE STRUCTURES 858 24.12 A SUMMARY VIEW: USING INHERITANCE WELL 862 24.13 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 863 24.14 BIBLIOGRAPHICAL NOTES 863 24.15 APPENDIX: A HISTORY OF TAXONOMY 864 EXERCISES 869 Chapter 25: Useful techniques 871 25.1 DESIGN PHILOSOPHY 871 25.2 CLASSES 872 25.3 INHERITANCE TECHNIQUES 873 Chapter 26: A sense of style 875 26.1 COSMETICS MATTERS! 875 26.2 CHOOSING THE RIGHT NAMES 879 26.3 USING CONSTANTS 884 26.4 HEADER COMMENTS AND INDEXING CLAUSES 886 26.5 TEXT LAYOUT AND PRESENTATION 891 26.6 FONTS 900 26.7 BIBLIOGRAPHICAL NOTES 901 EXERCISES 902 Chapter 27: Object-oriented analysis 903 27.1 THE GOALS OF ANALYSIS 903 27.2 THE CHANGING NATURE OF ANALYSIS 906 27.3 THE CONTRIBUTION OF OBJECT TECHNOLOGY 907 27.4 PROGRAMMING A TV STATION 907 27.5 EXPRESSING THE ANALYSIS: MULTIPLE VIEWS 914 27.6 ANALYSIS METHODS 917 27.7 THE BUSINESS OBJECT NOTATION 919 27.8 BIBLIOGRAPHY 922CONTENTS xxv Chapter 28: The software construction process 923 28.1 CLUSTERS 923 28.2 CONCURRENT ENGINEERING 924 28.3 STEPS AND TASKS 926 28.4 THE CLUSTER MODEL OF THE SOFTWARE LIFECYCLE 926 28.5 GENERALIZATION 928 28.6 SEAMLESSNESS AND REVERSIBILITY 930 28.7 WITH US, EVERYTHING IS THE FACE 933 28.8 KEY CONCEPTS COVERED IN THIS CHAPTER 934 28.9 BIBLIOGRAPHICAL NOTES 934 Chapter 29: Teaching the method 935 29.1 INDUSTRIAL TRAINING 935 29.2 INTRODUCTORY COURSES 937 29.3 OTHER COURSES 941 29.4 TOWARDS A NEW SOFTWARE PEDAGOGY 942 29.5 AN OBJECT-ORIENTED PLAN 946 29.6 KEY CONCEPTS STUDIED IN THIS CHAPTER 948 29.7 BIBLIOGRAPHICAL NOTES 948 PART E: ADVANCED TOPICS 949 Chapter 30: Concurrency, distribution, client-server and the Internet 951 30.1 A SNEAK PREVIEW 951 30.2 THE RISE OF CONCURRENCY 953 30.3 FROM PROCESSES TO OBJECTS 956 30.4 INTRODUCING CONCURRENT EXECUTION 964 30.5 SYNCHRONIZATION ISSUES 977 30.6 ACCESSING SEPARATE OBJECTS 982 30.7 WAIT CONDITIONS 990 30.8 REQUESTING SPECIAL SERVICE 998 30.9 EXAMPLES 1003 30.10 TOWARDS A PROOF RULE 1022 30.11 A SUMMARY OF THE MECHANISM 1025 30.12 DISCUSSION 1028 30.13 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 1032 30.14 BIBLIOGRAPHICAL NOTES 1033 EXERCISES 1035CONTENTS xxvi Chapter 31: Object persistence and databases 1037 31.1 PERSISTENCE FROM THE LANGUAGE 1037 31.2 BEYOND PERSISTENCE CLOSURE 1039 31.3 SCHEMA EVOLUTION 1041 31.4 FROM PERSISTENCE TO DATABASES 1047 31.5 OBJECT-RELATIONAL INTEROPERABILITY 1048 31.6 OBJECT-ORIENTED DATABASE FUNDAMENTALS 1050 31.7 O-O DATABASE SYSTEMS: EXAMPLES 1055 31.8 DISCUSSION: BEYOND O-O DATABASES 1058 31.9 KEY CONCEPTS STUDIED IN THIS CHAPTER 1060 31.10 BIBLIOGRAPHICAL NOTES 1061 EXERCISES 1062 Chapter 32: Some O-O techniques for graphical interactive applications 1063 32.1 NEEDED TOOLS 1064 32.2 PORTABILITY AND PLATFORM ADAPTATION 1066 32.3 GRAPHICAL ABSTRACTIONS 1068 32.4 INTERACTION MECHANISMS 1071 32.5 HANDLING THE EVENTS 1072 32.6 A MATHEMATICAL MODEL 1076 32.7 BIBLIOGRAPHICAL NOTES 1076 PART F: APPLYING THE METHOD IN VARIOUS LANGUAGES AND ENVIRONMENTS 1077 Chapter 33: O-O programming and Ada 1079 33.1 A BIT OF CONTEXT 1079 33.2 PACKAGES 1081 33.3 A STACK IMPLEMENTATION 1081 33.4 HIDING THE REPRESENTATION: THE PRIVATE STORY 1085 33.5 EXCEPTIONS 1088 33.6 TASKS 1091 33.7 FROM ADA TO ADA 95 1092 33.8 KEY CONCEPTS INTRODUCED IN THIS CHAPTER 1097 33.9 BIBLIOGRAPHICAL NOTES 1097 EXERCISES 1098CONTENTS xxvii Chapter 34: Emulating object technology in non-O-O environments 1099 34.1 LEVELS OF LANGUAGE SUPPORT 1099 34.2 OBJECT-ORIENTED PROGRAMMING IN PASCAL? 1100 34.3 FORTRAN 1102 34.4 OBJECT-ORIENTED PROGRAMMING AND C 1106 34.5 BIBLIOGRAPHICAL NOTES 1112 EXERCISES 1112 Chapter 35: Simula to Java and beyond: major O-O languages and environments 1113 35.1 SIMULA 1113 35.2 SMALLTALK 1126 35.3 LISP EXTENSIONS 1130 35.4 C EXTENSIONS 1131 35.5 JAVA 1136 35.6 OTHER O-O LANGUAGES 1137 35.7 BIBLIOGRAPHICAL NOTES 1138 EXERCISES 1139 PART G: DOING IT RIGHT 1141 Chapter 36: An object-oriented environment 1143 36.1 COMPONENTS 1143 36.2 THE LANGUAGE 1144 36.3 THE COMPILATION TECHNOLOGY 1144 36.4 TOOLS 1148 36.5 LIBRARIES 1150 36.6 INTERFACE MECHANISMS 1152 36.7 BIBLIOGRAPHICAL NOTES 1160 Epilogue, In Full Frankness Exposing the Language 1161

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值