读 Patterns of Enterprise Application Architecture 1

原创 2005年05月02日 23:56:00

 

Layering is an important technique, but there are downsides.

  • Layers encapsulate some, but not all, things well. As a result you sometimes get cascading changes. The classic example of this in a layered enterprise application is adding a field that needs to display on the UI, must be in the database, and thus must be added to every layer in between.

  • Extra layers can harm performance. At every layer things typically need to be transformed from one representation to another. However, the encapsulation of an underlying function often gives you efficiency gains that more than compensate. A layer that controls transactions can be optimized and will then make everything faster.

But the hardest part of a layered architecture is deciding what layers to have and what the responsibility of each layer should be.

 

层用来封装下层的,但不一定是完全的封装。封装数据结构会让层与层之间不得不,进行数据表达的转换,但封装行为确是会为这样的附加工作量得到补偿。到底该如何封装呢?
但最难确定是并不是这个,而是层化架构中的每一个层有什么,应该负责什么。

When people discuss layering, there's often some confusion over the terms layer and tier. Often the two are used as synonyms, but most people see tier as implying a physical separation. Client杝erver systems are often described as two-tier systems, and the separation is physical: The client is a desktop and the server is a server. I use layer to stress that you don't have to run the layers on different machines. A distinct layer of domain logic often runs on either a desktop or the database server. In this situation you have two nodes but three distinct layers. With a local database I can run all three layers on a single laptop, but there will still be three distinct layers.

层(layer) 与 层级(tier) 有点区别,可能用中文比较难以区分。都可以翻译成层次。很多人把 tier 理解成指物理上的分离。我们用layer 特指逻辑上的 分离层次。他们可以任意运行在一个或多个(物理)平台上

Three Principal Layers

Layer

Responsibilities

Presentation

Provision of services, display of information (e.g., in Windows or HTML, handling of user request (mouse clicks, keyboard hits), HTTP requests, command-line invocations, batch API)

Domain

Logic that is the real point of the system

Data Source

Communication with databases, messaging systems, transaction managers, other packages


以上是 martin fowler  所说的j2ee层次架构中 的三主要层次。presentation layer 就是与ui交互的部分。domain layer是核心逻辑部分。Data Source layer 是指于其它系统交互的部分。对于Data Source layer在实际情况中,其去很大一部分就是与数据库交互,所以对于与数据库等进行持久化操作的的Data Source layer有时也叫做 persistence layer。
这个模式只是 martin fowler等人的看法。其实,还有其他模式可以参考。比如:四层架构模式 (Four Layer Architecture) 六角形架构模(Hexagonal Architecture) 式等等。个人观点:我个人认为作为应用系统高级目标更倾向于六角形架构模式,而martin他们提出的模式,更适用于现在web应用或以使用人为核心应用系统的情况。个人感觉其缺乏普遍性。
http://c2.com/cgi/wiki?HexagonalArchitecture
http://c2.com/cgi/wiki?FourLayerArchitecture

版权声明:本文为博主原创文章,未经博主允许不得转载。

读Martin Fowler's 《Patterns of Enterprise Application Architecture》有感

作为一本技术指导书,显然这本书有些outdated了,但想想现在的一些框架,架构正是基于这本书的思想构建的,还是不免对作者当时的Vision感到钦佩。出于对这些思想本源的追索,以及对历史的追溯。还是很...

学习《企业应用架构模式》(Patterns of Enterprise Application Architecture)C01 分层

第一章 分层 参考 网络通讯的7层结构; 基于C/S系统结构中,分层概念更加明显; 三个基本层次: 表现层:提供服务,显示信息(处理用户请求(鼠标键盘),HTTP请求,命令行调用,批处理API);...

ABP-Enterprise Web Application Architecture

ABP 是一个融合了ASP.NET技术体系的企业web应用开发框架,主要有ASP.NET MVC / Web API 2.0 / EF 等等,并且支持IOC/多语言等特性。 ABP的官网网址:http...

Comparison of Architecture presentation patterns MVP(SC),MVP(PV),PM,MVVM and MVC

本文转载自 http://www.codeproject.com/Articles/66585/Comparison-of-Architecture-presentation-patterns-M ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:读 Patterns of Enterprise Application Architecture 1
举报原因:
原因补充:

(最多只允许输入30个字)