zoukankan      html  css  js  c++  java
  • 设计模式 之 Organizing the Catalog 组织目录


    Design patterns vary in their granularity and level of abstraction. Because thereare many design patterns, weneed a way to organize them. This section classifies design patterns so that we can refer tofamilies of related patterns. The

    classification helps you learn the patternsin the catalog faster, and it can direct efforts to find new patterns aswell.

    在抽象的粒度和和水平上,设计模式是多样化。由于有很多的设计模式,我们需要一种组织它们的方法。本节将设计模式分类,以至于我们可以更多地了解哪些相关联的设计模式。这种分类可以帮助你更快的学习这些设计模式。这也对你发现新的设计模式有影响。

    We classify design patterns by two criteria(Table 1.1). The first criterion, called purpose, reflects what a patterndoes. Patterns can have either creational,structural, or behavioral purpose.Creational patterns concern the process of

    object creation. Structural patterns dealwith the composition of classes or objects. Behavioral patterns characterizethe ways in which classes or objects interact and distribute responsibility.

    通过表1.1这两个标准, 我们将设计模式进行分类。第一个标准是目的,反映的是设计模式。模式可以有创造(造物)或结构或行为目的。创造模式关心的是对象创建的进程。结构处理的是类和对象的组成。行为模式的特征是类和对象的相互影响和分类。

    The second criterion, called scope,specifies详述,特性 whetherthe pattern applies primarily to classes or to objects. Classpatterns deal with relationships between classes and their subclasses. Theserelationships are established through

    inheritance, so they are static—fixed atcompile-time. Object patterns deal with object relationships, which can be changedat run-time and are more dynamic. Almost all patterns use inheritance to someextent. So the only patterns labeled "class

    patterns" are those that focus onclass relationships. Note that most patterns are in the Object scope.

    第二个标准是规模。提出模式是否应用于类和对象的条件。类模式处理类和子类之间的关系。这些关系已经在继承时确立,因此它是静态固定的编译。对象模式处理对象之间的关系。在执行时它可以被改变,它更多体现动态。在一定程度上,几乎所有的模式都用继承。因此只有“类模式”关注的是类之间的关系。注意更多地模式关注的是对象的规模。

    Creational class patterns defer some partof object creation to subclasses, while Creational object patterns defer it toanother object. The Structural class patterns use inheritance to composeclasses, while the Structural object patterns describe ways to assemble objects. TheBehavioral class patterns use inheritance to describe algorithms and flow of control,whereas the Behavioral object patterns

    describe how a group of objects cooperateto perform a task that no single object can carry out alone.

    创新类模式遵从部分对象到子类,创新对象模式遵从对象到其他的对象。结构类模式用继承来组成类,结构对象描述了组合对象的方法。行为类模式用继承来描述算法和流程控制。在这里行为类模式描述了一组对象合作完成任务,而不是单个对象可以独自执行可完成的。

    There are other ways to organize thepatterns. Some patterns are often used together.For example, Composite is often used withIterator or Visitor. Some patterns are alternatives: Prototype is often analternative to Abstract Factory. Some patterns result in similar designs even though thepatterns have different intents. For example, the structure diagrams ofComposite and Decorator are similar.

    也有一些其他的方法来组织模式。一些模式经常用在一起。例如,经常将迭代器模式和访问者模式结合在一起用。样板经常继承于抽象工厂模式。即使模式有不同的意图,一些设计却拥有类似的设计。例如,结构图的复合和装饰是相似的。

    Yet another way to organize design patternsis according to how they reference each other in their "RelatedPatterns" sections. Figure 1.1 depicts these relationships graphically.

    现在,其他的方法来组织设计模式是根据每个相关模式部分是如何引用的。图1.1生动的描述了这种关系。

    Clearly there are many ways to organizedesign patterns. Having multiple ways of thinking about patterns will deepen yourinsight into what they do, how theycompare, and when to apply them.

    准确的说有很多的方法来组织设计模式。有多个方法思考设计模式会加深你洞察它们是做什么的,会洞察它们是如何被比较,以及在什么时间应用它们。

  • 相关阅读:
    Python获取网页指定内容(BeautifulSoup工具的使用方法)
    python beautifulsoup 对html 进行爬取分类(部分)
    字典
    爬虫是什么
    pandas之DataFrame
    pandas之Ndarray
    pandas之Series
    爬取英文名详细内容
    python数据库连接
    python爬取昵称并保存为csv
  • 原文地址:https://www.cnblogs.com/aukle/p/3225788.html
Copyright © 2011-2022 走看看