Table Module
老马说:
A single instance that handles the business logic for all rows in a database table or view.
我说:一个实例操作所有一个数据库表或视图的业务逻辑。
One of the key messages of object orientation is bundling the data with the behavior that uses it
面向对象设计的一个关键点是把数据和操作他们的行为包装在一起。
The traditional object-oriented approach is based on objects with identity, along the lines of Domain Model 。
传统的面向对象设计方法是建立在对象的一致性基础之上的,沿着业务对象链。哈哈
Thus, if we have an Employee class, any instance of it corresponds to a particular employee.
因此,如果我们有一个(Employee类),所有它的实例符合一个特殊的(Employee)。
This scheme works well because once we have a reference to an employee, we can execute operations, follow relationships, and gather data on him.
这个设计能很好的工作,因为一但我们有一个对象的接口,我们就可以执行它的方法,关联关系,和在它身上收集数据。
One of the problems with Domain Model (116) is the interface with relational databases.
业务对象的一个问题在于和关系数据库的交互。
In many ways this approach treats the relational database like a crazy aunt who's shut up in an attic and whom nobody wants to talk about.
许多时候这种办法不能处理关系型数据库。
As a result you often need considerable programmatic gymnastics to pull data in and out of the database, transforming between two different representations of the data.
结果是你通常要考虑怎么把数据从数据库中取出插入,使其在不同的表现方式上转换。
A Table Module organizes domain logic with one class per table in the data-base, and a single instance of a class contains the various procedures that will act on the data.
Table Module用一个在数据库中的表来组织业务逻辑,它的一个实例包含许多不同的操作数据库的方法。
The primary distinction with Domain Model (116) is that, if you have many orders, a Domain Model (116) will have one order object per order while a Table Module will have one object to handle all orders.
和业务对象最大的不同是,如果你有许多的Orders,一个业务对象用一个Order对象来表达一个Order,而Table Module则用一个对象来表示所有的Orders。