??xml version="1.0" encoding="utf-8" standalone="yes"?> As we moved from one language to another, generally we increased the level of abstraction at which the developer operates, which required the developer to learn a new, higher-level language that could then be mapped into lower-level ones, from C++ to C to assembly code to machine code and the hardware. At first, each higher layer of abstraction was introduced only as a concept. The first assembly languages were no doubt invented without the benefit of an (automated) assembler to turn mnemonics into bits, and developers were grouping functions together with the data they encapsulated long before there was any automatic enforcement of the concept. Similarly, the concepts of structured programming were taught before there were structured programming languages in widespread industrial use (for instance, Pascal). 当我们从一U语a发展到另一U语a的时候,通常我们提高了开发者进行开发所处的抽象层次Q这需要开发者学?fn)新的、更高层ơ的能够映射C层次的语aQ如C++到C到汇~代码到机器码和g。最初,每一个更高层ơ的抽象只是作ؓ(f)一个概念被引入。最初的汇编语言被发明的时候,作ؓ(f)把助记符转换到字节码的汇~器q没有体pd什么明昄又是。。。。,cM的,l构化程序设计的概念也显得很不ؓ(f)人接受直到结构化~程语言在工业界qؓ(f)使用?br /> 随着旉的过去,然而,新的抽象层次也开始正式Ş成,相应的工具如汇编器、预处理器和~译器开始出C支持q些概念。它们把低抽象层ơ的l节隐藏Q得只有少数的专家Q如~译器的~写者)需要关心这些细节如何工作。。。。?br /> 随着开发者开发的抽象层次的提高,我们开发出从一个层ơ自动映到另一个层ơ的工具。开发者现在只需~写高层ơ的~程语言Q之后的转换是自动q行的?br /> 昄Q这形成了一U模式:(x)我们不断地提高抽象的层次的概念,随着旉的过去,我们学会(x)了如何用这U语a以及(qing)应用一pd的用约束。这些约束变成正式后一U新的语a诞生了,而这U下一代的语言是从低层ơ被感知的,当我们定义一pd的用约束之后,q些新的U束又被正式化,来推动下一阶段的发展。不断地循环?br />
In general, the organization of the data and processing implied by a conceptual model may not be the same as the organization of the data and processing in implementation. If we consider two concepts, those of "customer" and "account," modeling them as classes using the UML suggests that the software solution should be expressed in terms of software classes named Customer and Account. However, there are many possible software designs that can meet these requirements, many of which are not even object-oriented. Between concept and implementation, an attribute may become a reference; a class may be divided into sets of object instances according to some sorting criteria; classes may be merged or split; statecharts may be flattened, merged, or separated; and so on. A modeling language that enables such mappings is software-platform independent. The Single Choice principle: Traditional languages and paradigms do not provide a solution. On the other hand, object orientation, via polymorphism and dynamic binding present an elegant and complete implementation of this principle.
软g开发的历史是抽象层ơ不断提高的历史Q我们的工业以前是通过电(sh)路焊接在一起以形成gl成的程序,q样来进行系l的搭徏。机器码使得我们可以通过操作开x输入每条指o(h)Q数据保持在×××××。。。,后来Q汇~程序通过为每U硬件^台定义相应助记符的Ş式,帮我们把q种J琐?/1操作中解攑և来?br />
At some point, programming languages, such as FORTRAN, were born and "formula translation" became a reality. Standards for COBOL and C enabled portability among hardware platforms, and the profession developed techniques for structuring programs so that they were easier to write, understand, and maintain. We now have languages like Smalltalk, C++, Eiffel, and Java, each with the notion of object-orientation, an approach for structuring data and behavior together into classes and objects.
C后来Q编E语a诸如FORTRAN的出玎ͼ使得“公式翻译”成为现实,COBOL和C标准使得不同gq_之间的移植成为可能,后来发展Zl构化的E序设计方式Q得编E语a更容易编写、理解和l护。我们现在拥有像smalltalk、C++、Eiffel和JavaQ它们运用了面向对象技术,一U把数据和行为封装到cd对象的方法?/p>
Over time, however, the new layers of abstraction became formalized, and tools such as assemblers, preprocessors, and compilers were constructed to support the concepts. This had the effect of hiding the details of the lower layers so that only a few experts (compiler writers, for example) needed to concern themselves with the details of how those layers work. In turn, this raises concerns about the loss of control induced by, for example, eliminating the GOTO statement or writing in a high-level language at a distance from the "real machine." Indeed, sometimes the next level of abstraction has been too big a reach for the profession as a whole, only of interest to academics and purists, and the concepts did not take a large enough mindshare to survive. (ALGOL-68 springs to mind. So does Eiffel, but it has too many living supporters to be a safe choice of example.)
As the profession has raised the level of abstraction at which developers work, we have developed tools to map from one layer to the next automatically. Developers now write in a high-level language that can be mapped to a lower-level language automatically, instead of writing in the lower-level language that can be mapped to assembly language, just as our predecessors wrote in assembly language and had that translated automatically into machine language.
Clearly, this forms a pattern: We formalize our knowledge of an application in as high a level a language as we can. Over time, we learn how to use this language and apply a set of conventions for its use. These conventions become formalized and a higher-level language is born that is mapped automatically into the lower-level language. In turn, this next-higher-level language is perceived as low level, and we develop a set of conventions for its use. These newer conventions are then formalized and mapped into the next level down, and so forth.
The next level of abstraction is the move, shown in Figure 1-1, to model-based development, in which we build software-platform-independent models.
下一阶段的抽象层ơ在发展Q如图所C。它是基于模型的开发,在这里我们徏立的是和软gq_无关的模型?br />
Figure 1-1. Raising the level of abstraction
Software-platform independence is analogous to hardware-platform independence. A hardware-platform-independent language, such as C or Java, enables the writing of a specification that can execute on a variety of hardware platforms with no change. Similarly, a software-platform-independent language enables the writing of a specification that can execute on a variety of software platforms, or software architecture designs, with no change. So, a software-platform-independent specification could be mapped to a multiprocessor/multitasking CORBA environment, or a client-server relational database environment, with no change to the model.
软gq_无关是和gq_无关cM的概c(din)一个硬件^台无关的语言Q如C或者JavaQ可以得一个规范的~写能够在不同的gq_上运行而不需要更攏V类似地Q一个Y件^台无关的语言可以使得一个规范的~写可以在不同的软gq_上运行,或者在不同的Y件架构中q行Q而不需要更攏V因此,一个Y件^台无关的规范可以映射到多处理?多Q务CORBA环境Q或者一个C-S关系数据库环境,而不需要更Ҏ(gu)型?br />
ȝ而言Q由概念模型所驱动的数据的l成和处理也许和实际的数据组成和处理不完全相同。如果我们考虑两个概念Q比如“customer”和“Account”,他们徏模程UML的类图以期望能够被用?/p>
whenever a software system must support a set of variants, clients using objects from this set should not have knowledge of all the elements in the set. A violation of this principle can be illustrated with the variants of Pascal or the unions of C (as long as the union is placed inside a struct and there is a field that acts as a type descriptor). Code written that acts upon one of these “multiple personality entities? must be queried for its actual type, and we must program accordingly. This will produce multiple selection constructs in any module that uses these variant types.
Such constructs will become a hindrance to software change and evolution. Any addition of a new type to the variant set will force modifications in all modules that have to query the type to act accordingly. This multiple choices spread around many modules of a system is exactly the opposite to the single choice principle.
This concludes our consideration of the properties necessary for good modular structures. It will be seen that Abstract Data Types provide an adequate specification for modules that are consistent with the properties developed in this section. Eventually, we will cross the bridge into the software world and introduce the class as a potentially partial implementation of an Abstract Data Type.
]]>
W二?an Introduction to Patterns
一开始通过一个例子引入Observer PatternQ在q本书中Q对模式的描q是用以下格式来q行的:(x)
在第三章Q介l了OO相关技术包括UMLQ其中提C一个概念:(x)在一个承体pMQ良好的做法是越往上放多的CodeQ而Data则放到越下层Q子cor实现c)好。文章是q样解释的:(x)公׃码尽可能地放到承层ơ的上方q样它可以被重用Q和数据不同Q在l承的过E中Q当子类实例不需要用的时候,代码也不?x)有额外的costQ,而数据元素则应该攑ֈ低好Q这样你不会(x)Z需使用的数据成员付Z仗如下图Q?br />
W四章讲的是一个电(sh)脑公司的销售系l,寚w件的零售和各U搭配销售,要求pȝ能够l一对待Q这里引入了Composite模式Q这里不详述Q因是比较简单的?br />
W五章讲的是Decorator模式Q首先引入了一个汉堡店的系l,介绍了组合爆炸的设计Qƈ引入DecoratorQ解决了q种问题?br />
W六章讲的是不同~程语言Ҏ(gu)式的实现问题Q设计模式和?fn)惯用法QidiomQ比较v来,后者是与特定语a相关的,而设计模式则是与语言无关的,q指的是支持OO的语a都支持设计模式,只不q实现v来的复杂E度各有不同Q文章D了一个例子用VB来实现State模式Q再用Java来实玎ͼ得出上述l论?br />
W七章第八章我就没详l看了,一是觉得这里的囄的不是标准UML图,看v来不太顺|另一个则是内容似乎没什么特别的。书的最后三分之一都是附录Q代码?br />
ȝ而言Q这本书不算一本经典的书,׃在图书馆借的Q在q书之前M一下。下ơ打看的模式书是《Head First Design Pattern》。不q得{辩之后才有旉了?/p>