POSA Vol.1 EP2, Architectural Patterns

1. 架构最基本最简单的思想就是分层, 也有人说是责任分离.

2. 适应软件变化就是引入中间层.

Chapter 2摘要

  PⅠ:

 - The Layers architectural pattern helps to structure applications that can be decomposed into groups of subtasks in which each group of subtasks is at a particular level of abstraction.

 - The Pipes and Filters architectural pattern provides a structure for systems that process a stream of data. Each processing step is encapsulated in a filter component. Data is passed through pipes between adjacent filters. Recombining filters allows you to build families of related systems.

  PⅡ:

 - The Model-View-Controller architectural pattern (MVC) divides an interactive application into three components. The model contains the core functionality and data. Views display information to the user. Controllers handle user input. Views and controllers together comprise the user interface. A change-propagation mechanism ensures consistency between the user interface and the model.

 - The Presentation-Abstraction-Control architectural pattern (PAC) defines a structure for interactive software systems in the form of a hierarchy of cooperating agents. Every agent is responsible for a specific aspect of the application's functionality and consists of three components: presentation, abstraction, and control. This subdivision separates the human-computer interaction aspects of the agent from
its functional core and its communication with other agents.

 - The agent's presentation component provides the visible behavior of the PAC agent. Its abstraction component maintains the data model that underlies the agent, and provides functionality that operates on this data. Its control component connects the presentation and abstraction components, and provides fimctionality that allows the agent to communicate with other PAC agents.

--------------------------------

结构的划分可以为2个层面: 横,按功能模块,比如MIS中的登陆,注册与管理; 纵,按调用(依赖),比如web的3层结构,OSI 7层结构.
MVC,Layers与Pipes可以归为纵结构;PAC为横结构.

1. Layers注重层次之间的访问级别, Layer K只为Layer K+1提供接口与抽象, 并将本层的访问委托到Layer K-1, 对其余层皆透明.

2. Pipes的层次关系非常淡化, 由于各层次之间没有严格的先后关系, 所以方便重组与复用.

3. MVC是VS创建web程序使用的一种架构: .aspx可以看做view, .cs看做control, 其余的逻辑层次统作为model. 但从某种角度可以说这种web开发过程并没有应用到MVC的最大优势, 即multiviews与model的同步. 因为在这样的映射下, model并没有提供一种抽象机制作用于view的协作(相对webform的存在), VS下的model和view总是保持1:1甚至是N:1的关系(1:N才是正确的映射). 不同的是.Net 3.0引入的绑定元素(binding elements): 当改变源数据时, 所有依赖其的数据都会得到更新. 我们可以把源数据看做model, 绑定数据看做view, 正是由于.net 3.0中的绑定机制的存在(作用于model与view),  当我们在任意时刻改变源数据(control作用), 所有相关的绑定数据都会正确并即时的更新. View userInput Control, Control change Model, Model update View, View retrieve date Model, Control display View.

4. MVC和3层结构(Layers)是2个概念, 没有一定的对应关系. 他们的共同点仅仅是模块化, 并实现责任分离. 3层结构关注的是层次的划分, 以更有条理的方式组织代码, 邻接的层次有非常强的依赖关系(From mud to structure); MVC关注的是view与model之间的协作与同步, 以方便变化的及时反映, 各模块之间并没有强烈的依赖(Interactive).

5. PAC由于任意具体功能都会聚集在一个bottom-level PAC agents, 所以非常适合plug-in模式. Top-level提供数据与接口给intermediate-level, intermediate-level提供数据接口给bottom-level, 也就是说, bottom依赖intermediate, intermediate依赖top.

posted @ 2009-06-10 01:29  Tyrael  阅读(283)  评论(0编辑  收藏  举报