One of the key messages of object orientation is bundling the data wit translation - One of the key messages of object orientation is bundling the data wit English how to say

One of the key messages of object o

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 (116). Thus, if we have an Employee class, any instance of it corresponds to a particular 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 database, and a single instance of a class contains the various procedures that will act on the data. 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.

How It Works
The strength of Table Module is that it allows you to package the data and behavior together and at the same time play to the strengths of a relational database. On the surface Table Module looks much like a regular object. The key difference is that it has no notion of an identity for the objects it's working with. Thus, if you want to obtain the address of an employee, you use a method like anEmployeeModule.getAddress(long employeeID). Every time you want to do something to a particular employee you have to pass in some kind of identity reference. Often this will be the primary key used in the database.

Usually you use Table Module with a backing data structure that's table oriented. The tabular data is normally the result of a SQL call and is held in a Record Set (508) that mimics a SQL table. The Table Module gives you an explicit method-based interface that acts on that data. Grouping the behavior with the table gives you many of the benefits of encapsulation in that the behavior is close to the data it will work on.

Often you'll need behavior from multiple Table Modules in order to do some useful work. Many times you see multiple Table Modules operating on the same Record Set (508) (Figure 9.4).


09fig04.gif
Figure 9.4 Several Table Modules can collaborate with a single Record Set (508).

The most obvious example of Table Module is the use of one for each table in the database. However, if you have interesting queries and views in the database you can have Table Modules for them as well.

The Table Module may be an instance or it may be a collection of static methods. The advantage of an instance is that it allows you to initialize the Table Module with an existing record set, perhaps the result of a query. You can then use the instance to manipulate the rows in the record set. Instances also make it possible to use inheritance, so we can write a rush contract module that contains additional behavior to the regular contract.

The Table Module may include queries as factory methods. The alternative is a Table Data Gateway (144), but the disadvantage of this is having an extra Table Data Gateway (144) class and mechanism in the design. The advantage is that you can use a single Table Module on data from different data sources, since you use a different Table Data Gateway (144) for each data source.

When you use a Table Data Gateway (144) the application first uses the Table Data Gateway (144) to assemble data in a Record Set (508). You then create a Table Module with the Record Set (508) as an argument. If you need behavior from multiple Table Modules, you can create them with the same Record Set (508). The Table Module can then do business logic on the Record Set (508) and pass the modified Record Set (508) to the presentation for display and editing using the table-aware widgets. The widgets can't tell if the record sets came directly from the relational database or if a Table Module manipulated the data on the way out. After modification in the GUI, the data set goes back to the Table Module for validation before it's saved to the database. One of the benefits of this style is that you can test the Table Module by creating a Record Set (508) in memory without going to the database.


09fig05.gif
Figure 9.5 Typical interactions for the layers around a Table Module.

The word “table” in the pattern name suggests that you have one Table Module per table in the database. While this is true to the first approximation, it isn't completely true. It's also useful to have a Table Module for commonly used views or other queries. Indeed, the structure of the Table Module doesn't really depend on the structure of tables in the database but more on the virtual tables perceived by the application, including views and queries.

When to Use It
Table Module is very much based on table-oriented data, so obviously using it makes sense when you're accessing tabular data using Record Set (508). It also puts that data structure very much in the center of the code, so you also want the way you access the data structure to be fairly straightforward.

However, Table Module doesn't give you the full power of objects in organizing complex logic. You can't have direct instance-to-instance relationships, and polymorphism doesn't work well. So, for handling complicated domain logic, a Domain Model (116) is a better choice. Essentially you have to trade off Domain Model (116)'s ability to handle complex logic against Table Module's easier integration with the underlying table-oriented data structures.

If the objects in a Domain Model (116) and the database tables are relatively similar, it may be better to use a Domain Model (116) that uses Active Record (160). Table Module works better than a combination of Domain Model (116) and Active Record (160) when other parts of the application are based on a common table-oriented data structure. That's why you don't see Table Module very much in the Java environment, although that may change as row sets become more widely used.

The most well-known situation in which I've come across this pattern is in Microsoft COM designs. In COM (and .NET) the Record Set (508) is the primary repository of data in an application. Record sets can be passed to the UI, where data-aware widgets display information. Microsoft's ADO libraries give you a good mechanism to access the relational data as record sets. In this situation Table Module allows you to fit business logic into the application in a well-organized manner, without losing the way the various elements work on the tabular data.

Example: Revenue Recognition with a Table Module (C#)
Time to revisit the revenue recognition example (page 112) I used in the other domain modeling patterns, this time with a Table Module. To recap, our mission is to recognize revenue on orders when the rules vary depending on the product type. In this example we have different rules for word processors, spreadsheets, and databases.

Table Module is based on a data schema of some kind, usually a relational data model (although in the future we may well see an XML model used in a similar way). In this case I'll use the relational schema from Figure 9.6.


09fig06.gif
Figure 9.6 Database schema for revenue recognition.

The classes that manipulate this data are in pretty much the same form; there's one Table Module class for each table. In the .NET architecture a data set object provides an in-memory representation of a database structure. It thus makes sense to create classes that operate on this data set. Each Table Module class has a data member of a data table, which is the .NET system class corresponding to a table within the data set. This ability to read a table is common to all Table Modules and so can appear in a Layer Supertype (475).
5000/5000
From: Detect language
To: English
Results (English) 1: [Copy]
Copied!
One of those thông điệp chính of định hướng objects been bundling of the data with hành vi sử dụng it. Cách tiếp cận hướng objects truyền thống based on the objects sắc, dọc theo dòng Domain Model (16). Như vậy , if we have a lớp nhân viên, bất kỳ thể hiện of its associated with one nhân viên cụ thể. This program hoạt động tốt because one on our have an references a nhân viên, we can be thực hiện hoạt động the, hay lam theo the mối quan hệ, and thu thap dữ liệu về anh ta. Một in the vấn đề với Domain Model (16) is giao diện with cơ sở dữ liệu quan hệ. Trọng multiple cách tiếp cận this argument xử with cơ sở dữ liệu quan hệ as one cô điên người been bọc kín in one căn gác and which is người ai muốn nói về. Kết quả that you need thường xuyên tập thể dục theo chương trình đáng kê đề kéo dữ liệu input and from cơ sở dữ liệu, chuyển đổi between đại diện khác nhau of dữ liệu. Một Bảng đun tổ chức luận lý tên miền with one per lớp cho bảng in cơ sở dữ liệu, and one trường hợp duy nhất of one has lớp contain the thủ tục khác nhau which would hành động on the dữ liệu. Sự khác biệt chính with the Domain Model (116) is, if you more đơn đặt hàng, one mô hình Domain (16) will have an argument tượng đơn hàng on an trật tự during an bảng Mô-đun will object to process all đơn đặt hàng. Chương trình hoạt động mạnh of panel module is it cho phép bạn đóng gói dữ liệu and hành vi with the and nhau tại same thời gian chơi với thế mạnh of one cơ sở dữ liệu quan hệ. Trên bề mặt Bảng đun trông as object thường xuyên. Sự khác biệt chính is it does not have khái niệm về a copy of sắc cho objects it làm việc. Vì vậy, if you want be address of one nhân viên, bạn sử dụng phương pháp one like anEmployeeModule.getAddress (EmployeeID dài). Every when you wish to one làm gì đó cho an nhân viên đặc biệt you must be beyond qua in one số loại sắc tài liệu tham khảo. Thường thì this will be chìa khóa chính be used in the cơ sở dữ liệu. Thông thường bạn sử dụng Bảng đun with one cấu trúc dữ liệu ủng hộ thats lý those bảng hướng. Các dữ liệu dạng bảng is usually kết quả of one cuộc gọi SQL and are tổ chức tại one Set Record (50 8) bắt chược one bảng SQL. Bảng Mô-đun cung cấp cho you a giao diện based on phương pháp rõ ràng that hoạt động on the dữ liệu then. Việc phân group of hành vi with the bàn mang lại cho bạn nhiều lợi ích of đóng gói in which hành vi this is near the data for it will work on '. Thường thì you will have hành vi thập từ nhiều Modules Bảng để làm of some công việc hữu ích. Nhiều lần bạn nhìn see more Modules Bảng hoạt động cùng on the Ghi Set (50 8) (Hình 9.4). 09fig04. gif Hình 9. Một số cho mô-đun Bảng possible cộng tác with one bản ghi Set duy nhất (508). Sau danh từ rõ ràng nhất of panel module is việc sử dụng one for each of bảng in cơ sở dữ liệu. Tuy nhiên, if you thắc mắc thú vị and quan điểm in cơ sở dữ liệu, you can be bảng Mô-đun cho they are tốt. Các Bảng Mô-đun you can be a examples or it may be one file hợp các phương pháp tĩnh. Lợi thế of one thể hiện is it cho phép bạn khởi tạo the Table đun with one bộ hồ sơ hiện có, might as one of the Kết quả truy vấn. After that, you can use the example for the thao tác hàng in tập hợp bản ghi. Instances also make it can use thừa kế, because vậy we may be one viết mô-đun đồng vội vàng store hành vi bổ sung cho các hợp đồng thường xuyên. Các Bảng Mô-đun possible includes files truy vấn phương pháp like nhà máy. Cách khác is one of the data Bảng Gateway (144), but bất lợi of this is no việc thêm Bảng liệu Gateway (144) đẳng cấp and cơ chế in thiết kế. Ưu điểm that you can use one bảng mo- đun duy nhất on the data from the nguồn dữ liệu khác nhau, since when you use one khác nhau Bảng liệu Gateway (144) for each of nguồn dữ liệu. When you use one dữ liệu Bảng Gateway (144) the application đầu tiên use dữ liệu bảng Gateway (144) for tổng hợp số liệu in one Set Record (508). Sau đó bạn create an đun Bảng with the Set Record (50 8) as argument. If you need hành vi từ multiple Modules bảng, you can be made ​​with their Ghi Cung Đặt (508). Bảng mô-đun then you can làm lý kinh doanh on the Set Record (50 8) and beyond through sửa đổi Ghi Set (50 8) to present to display and chỉnh sửa bằng cách use vật dụng bảng-aware. Các phụ tùng not nói if bộ hồ sơ trực tiếp to từ cơ sở dữ liệu quan hệ or if one đun Bảng thao tác data on đường ra. After sửa đổi in giao diện, tập dữ liệu đi lại cho the Table Mô-đun cho xác nhận before it be saved vào cơ sở dữ liệu. Một lợi ích in the the phong this way you are not check Bảng đun bằng cách tạo ra an Set Record (50 8) in memory but do not to cơ sở dữ liệu. 09fig05. gif Hình 9.5 tương tác tiêu biểu cho lớp xung quanh the one Bảng Module. Từ "Bang" trong tên mẫu cho be found that you have a bảng Mô-đun cho per bảng in cơ sở dữ liệu. While this is true as xấp xỉ đầu tiên, it does not hoàn toàn đúng sự thật. It also useful for has an đun Bảng cho điểm thường use or truy vấn khác. Thật vậy, cấu trúc of bảng Mô-đun no thực sự depends on cấu trúc of bảng in cơ sở dữ liệu but more on the tables ảo cảm nhận of the application includes cả quan điểm and câu truy vấn. Khí to use it Bảng đun are many based on dữ liệu bảng theo định hướng, because vậy rõ ràng is use it làm cho cảm giác of you on truy cập vào dữ liệu bảng sử dụng Ghi Set (508). It also that đặt cấu trúc dữ liệu many in the trung tâm mã, because you wish to vậy theo cách bạn truy cập into cấu trúc dữ liệu đơn giản is khá. Tuy nhiên, Bảng Mô-đun no cung cấp cho bạn toàn bộ sức mạnh of the objects in tổ chức phức tạp luận. You Can not have trực tiếp examples-to-examples mối quan hệ, and do not đa hình làm việc tốt. Vì vậy, để xử lý luận lý tên miền phức tạp, one mô hình Domain (116) as a selection better. Về cơ bản, you must đánh đổi Domain Model (16) 's capabilities xử lý luận lý phức tạp against the Bảng mô-đun dễ dàng than tích hợp with bảng định hướng cấu trúc dữ liệu cơ bản. If the objects in one mô hình Domain (16) and other bảng cơ sở dữ liệu is relative giống nhau, it could be better for using a mô hình Domain (16) have sử dụng Active Record (160). Bảng đun hoạt động better with one nên sự kết hợp of Domain Model (16) and Active Record (160) khi the phần khác of the application be based on one cấu trúc dữ liệu bảng theo định hướng chung. Độ is lý làm bạn không xem Bảng đun many in môi trường Java, mặc though điều That can change like bộ hàng trở thành sử dụng rộng rải than. Tình hình nổi tiếng nhất in which the maximum đi qua mô hình this is in the thiết kế Microsoft COM. Trọng COM (and. NET) Set Record (50 8) is kho lưu trữ chính of data in one ứng dụng. bộ ghi be converted to giao diện, nơi which the vật dụng dữ liệu nhận thức hiển thị thông tin. thư viện Microsoft ADO cung cấp cho you a cơ chế tốt to access the dữ liệu quan hệ like bộ hồ sơ. Trong tình huống this Bảng Mô-đun cho . allow you for phù hợp for lý kinh doanh into ứng dụng one has cách tổ chức, which is the làm mất yếu tố khác nhau cách làm việc trên các hệ bảng dữ liệu danh từ: Doanh thu nhận with one Bảng Module (Cc) Thời gian xem lại to the example ghi nhận doanh thu (trang 112) Tôi used in the mô hình mô hình miền khác, lần this with one bảng Module. To nhớ lại, sứ mệnh of we are for writing nhận doanh thu on the Order of on quy tắc khác nhau tùy vào loại sản part phẩm. Trọng examples this, we have the following quy định khác nhau cho xử lý văn bản, bảng tính, cơ sở dữ liệu and. Bảng đun are based on giản đồ dữ liệu của one số loại, is usually a mô hình dữ liệu quan hệ (mặc even in the future Chung ta also see one mô hình XML be used in one cách tương tự). Trong trường hợp this Toi se use lược đồ quan hệ in hình 9.6. 09fig06. gif hình đồ 9.6 Cơ sở dữ liệu ghi nhận doanh thu. Các lớp học which thao tác dữ liệu this is khá nhiều like hình thức; theres one lớp Bảng đun cho per bảng. Trong. NET kiến trúc object tập hợp dữ liệu provide a đại diện in memory of one cấu trúc cơ sở dữ liệu. Do that, it làm cho tinh thần to create a ra the lớp học hoạt động trên các hệ tập dữ liệu this. Every lớp mô-đun Bảng have a thành viên dữ liệu của bảng dữ liệu an, which is. NET lớp hệ thống tương ứng with one bảng in tập hợp dữ liệu. Khả năng this to read one is bảng chung cho tất cả the Module Bảng and làm which can be appear in one lớp siêu kiểu (475).
Being translated, please wait..
Results (English) 2:[Copy]
Copied!
One of those thông điệp chính of định hướng objects been bundling of the data with hành vi sử dụng it. Các cách tiếp cận hướng objects truyền thống based on the objects sắc, dọc theo dòng Domain Model (116). Vì vậy, if they have a ta lớp nhân viên, bất kỳ thể hiện of its associated with one nhân viên đặc biệt. This program hoạt động tốt because one on our have an references a nhân viên, we have not perform the activities, hay lam theo the mối quan hệ, thu thập dữ and liệu về anh ta. Một in the vấn đề với Domain Model (116) is giao diện with cơ sở dữ liệu quan hệ. Trọng multiple cách tiếp cận this argument xử with cơ sở dữ liệu quan hệ as one of the following cô điên người im lặng in one căn gác and which is người ai muốn nói về. Kết quả that you thường cần thể dục chương trình đáng kê đề kéo data to and from cơ sở dữ liệu, chuyển đổi between đại diện khác nhau of dữ liệu. Một Bảng đun tổ chức luận lý tên miền with one per lớp cho bảng in cơ sở dữ liệu, and one trường hợp duy nhất the one lớp contain the thủ tục khác nhau which would hành động on the dữ liệu. Sự khác biệt chính as mô hình Domain (116) is, if you more đơn đặt hàng, one mô hình Domain (116) will be object đơn hàng on an trật tự during an bảng Mô-đun will object to process all đơn đặt hàng. Chương trình hoạt động Sức mạnh of panel module is it cho phép bạn đóng gói dữ liệu and hành vi with the and same nhau lúc chơi for those thế mạnh of one cơ sở dữ liệu quan hệ. Trên bề mặt Bảng đun trông as object thường xuyên. Sự khác biệt chính is it does not have khái niệm về a copy of argument sắc cho tượng it làm việc với. Vì vậy, if you want be address of one nhân viên, bạn sử dụng phương pháp one like anEmployeeModule.getAddress (EmployeeID dài). Every when you wish to one làm gì đó cho an nhân viên đặc biệt you must be beyond qua in one số loại tài liệu tham khảo danh tính. Thường thì this will be chìa khóa chính be used in the cơ sở dữ liệu. Thông thường bạn sử dụng Bảng đun with one cấu trúc dữ liệu ủng hộ which is bảng theo định hướng. Các bảng dữ liệu is usually kết quả of one cuộc gọi SQL and are tổ chức tại one Set Record (508) bắt chược one bảng SQL. Bảng Mô-đun cung cấp cho you a giao diện based Trên phương pháp rõ ràng that hoạt động on the dữ liệu then. Nhóm of hành vi with the bàn mang lại cho bạn nhiều lợi ích of đóng gói in which hành vi this is near the data for it will work on '. Thường thì you will need right hành vi thập từ nhiều Modules Bảng để làm of some công việc hữu ích. Nhiều lần bạn nhìn see more Bảng Modules hoạt động cùng on the Ghi Set (508) (Hình 9.4). 09fig04.gif Hình 9.4 Một số mô-đun Bảng possible cộng tác with one bản ghi Set duy nhất (508). Sau danh từ rõ ràng nhất of panel module is using a cho per bảng in cơ sở dữ liệu. Tuy nhiên, if you thắc mắc thú vị and quan điểm in cơ sở dữ liệu bạn may have bảng Mô-đun cho they are tốt. Các Bảng Mô-đun be be a examples or it may be one file hợp các phương pháp tĩnh. Các lợi thế of one thể hiện is it allows you initialize the Table đun with one bộ hồ sơ hiện có, might as kết quả of one truy vấn. Sau đó bạn has not use for example thao tác in the hàng tập hợp bản ghi. Trường hợp also make it can use thừa kế, because vậy we may be one viết mô-đun đồng vội vàng store hành vi bổ sung cho các hợp đồng thường xuyên. Các Bảng Mô-đun possible includes files truy vấn phương pháp like nhà máy. Thay thế be a dữ liệu Bảng Gateway (144), but bất lợi of this is việc have a (144) đẳng cấp and cơ chế Data Table thêm Cổng in thiết kế. Ưu điểm that you can use one mô-đun duy nhất on the bảng dữ liệu from nguồn dữ liệu khác nhau, since when you use one khác nhau Bảng liệu Gateway (144) for each of nguồn dữ liệu. When you use one dữ liệu Bảng Gateway (144) Các ứng dụng đầu tiên sử dụng Bảng liệu Gateway (144) for tổng hợp số liệu in one Set Record (508). After that, you make a Mô-đun Bảng with the Set Record (508) as argument. If you need hành vi thập từ nhiều Modules bảng, you possible tạo ra them with Ghi cùng Set (508). After that the Table đun possible làm lý kinh doanh on the Set Record (508) and beyond through sửa đổi Ghi Set (508) to present to display and chỉnh sửa bằng cách use vật dụng bảng-aware. Các vật dụng not nói if bộ hồ sơ trực tiếp to từ cơ sở dữ liệu quan hệ or if one đun Bảng thao tác data on đường ra. After sửa đổi in giao diện, the bộ dữ liệu đi lại to Bảng đun cho xác nhận before it be saved vào cơ sở dữ liệu. Một lợi ích in the the phong this way you are not check Bảng đun bằng cách tạo ra an Set Ghi (508) in memory but do not to cơ sở dữ liệu. 09fig05.gif Hình 9.5 tương tác tiêu biểu cho lớp xung quanh the one Bảng Module. Từ "Bang" trong tên mẫu cho be found that you have a bảng Mô-đun cho per bảng in cơ sở dữ liệu. during this is true as xấp xỉ đầu tiên, it does not hoàn toàn đúng. It also useful for has an đun Bảng cho điểm thường use or truy vấn khác. Thật vậy, cấu trúc of bảng Mô-đun no thực sự depends on cấu trúc of bảng in cơ sở dữ liệu but more on the tables ảo cảm nhận of the application includes cả quan điểm and câu truy vấn. Khí for use it Bảng đun be many based on Bảng- dữ liệu theo định hướng, because vậy rõ ràng is use it có ý nghĩa when you đang truy cập dữ liệu dạng bảng sử dụng Ghi Set (508). It also đặt that cấu trúc dữ liệu many in the trung tâm of this code, because you wish to vậy theo cách bạn truy cập into cấu trúc dữ liệu đơn giản is khá. Tuy nhiên, Bảng Mô-đun no cung cấp cho bạn toàn bộ sức mạnh of the objects in tổ chức phức tạp luận. You Can not have trực tiếp Du Du-to-mối quan hệ, and do not đa hình làm việc tốt. Vì vậy, để xử lý luận lý tên miền phức tạp, one mô hình Domain (116) as a selection better. Về cơ bản, you must đánh đổi Domain Model (116) 's capabilities xử lý luận lý phức tạp against hội nhập dễ dàng than Bảng đun with the table hướng cấu trúc dữ liệu cơ bản. If the objects in one mô hình Domain (116) and other bảng cơ sở dữ liệu is relative giống nhau, it could be better for using a mô hình Domain (116) has sử dụng Active Record (160). Bảng mô-đun làm việc better with one nên sự kết hợp of Domain Model (116) and Active Record (160) khi the phần khác of the application be based on one cấu trúc dữ liệu bảng theo định hướng chung. Độ is lý làm tại sao bạn không xem Bảng đun many in môi trường Java, mặc though điều That can change like bộ hàng trở thành sử dụng rộng rải than. Tình hình nổi tiếng nhất which the maximum đi qua mô hình this is in the thiết kế Microsoft COM. Trọng COM (and .NET) Ghi Set (508) is kho lưu trữ chính of data in one ứng dụng. Bộ hồ sơ be converted to giao diện, nơi which the vật dụng dữ liệu nhận thức hiển thị thông tin. Thư viện ADO of Microsoft cung cấp cho you a cơ chế tốt to access the dữ liệu quan hệ like bộ hồ sơ. Trong tình huống this Bảng Mô-đun cho phép bạn to phù hợp for lý kinh . doanh into ứng dụng one has cách tổ chức, but no mất đi theo cách of yếu tố khác nhau làm việc trên các hệ bảng dữ liệu danh từ: Doanh thu nhận with one Bảng Module (C #) Thời gian for xem lại doanh thu công nhận examples (trang 112) Tôi used in the mô hình mô hình miền khác, lần this with one bảng Module. To nhớ lại, sứ mệnh of we are for writing nhận doanh thu on the Order of on quy tắc khác nhau tùy vào loại sản part phẩm. Trọng examples this, we have the following quy định khác nhau cho xử lý văn bản, bảng tính, cơ sở dữ liệu and. Bảng đun are based on giản đồ dữ liệu của of some loại, is usually a mô hình dữ liệu quan hệ (mặc even in the future Chung ta also see one mô hình XML be used in one cách tương tự). In this case Toi se use lược đồ quan hệ . in hình 9.6 09fig06.gif Hình Độ 9.6 Cơ sở dữ liệu ghi nhận doanh thu. Các lớp học which thao tác dữ liệu this is khá nhiều like hình thức; . have a lớp Bảng đun cho per bảng Trọng kiến trúc .NET object tập hợp dữ liệu provide a đại diện in memory of one cấu trúc cơ sở dữ liệu. Do that, it làm cho tinh thần to create a ra the lớp học hoạt động trên các hệ tập dữ liệu this. Every lớp học Bảng đun have a thành viên dữ liệu của bảng dữ liệu an, which is lớp hệ thống NET associated with one bảng in tập hợp dữ liệu. Khả năng this to read one is bảng chung cho all mô-đun Bảng and làm That thể xuất hiện in one lớp siêu kiểu (475).
















































Being translated, please wait..
Results (English) 3:[Copy]
Copied!
一个面向对象的关键信息是捆绑数据和行为,使用它。传统的面向对象的方法是基于对象的标识,在领域模型中的线(116)。因此,如果我们有一个Employee类的任何实例,它对应于一个特定的员工。该计划运作良好,因为我们曾经有一个员工,我们可以执行的操作,跟踪关系,和在它身上收集数据。领域模型的一个问题(116)与关系数据库的接口。在许多方面,这种方法将关系数据库的疯狂阿姨的关在阁楼里,谁也不想谈。

结果是你通常需要大量的编程训练拉数据的数据库中的数据,使其在不同的表现方式。表模块组织业务逻辑与数据库中每个表的一类,和一个类的实例包含各种程序将根据数据。域模型的主要区别是:(116),

如果你有多的订单,一个域模型(116)将每一阶阶对象而表模块将有一个对象处理所有订单。它是如何工作的表模块的优势在于它可以封装数据和行为结合在一起,同时发挥了关系数据库的优势。表面上表模块,看起来更像一个正规的对象。


关键的区别是,它没有概念,它的工作对象的身份。因此,如果你想获得一个员工的地址,你使用的方法如anemployeemodule getaddress(长EmployeeID)。每一次你想做一些特定的员工必须在某种身份引用传递。这常常会被用来在数据库中的主键。

通常你用表模块以支持数据结构的面向表。表格数据通常是一个SQL调用的结果并保存在一个记录集(508)模仿SQL表。表模块给你一个明确的方法为基础的界面,这些数据的行为。用表分组的行为给了你许多封装的好处,行为数据接近它将工作。通常你需要以便从多个表模块的行为做一些有用的工作。多少次你看到多台模块工作在相同的记录集(508)(图9.4)。09fig04 GIF图9。





4几台模块可以与一个单一的记录集合作(508)表模块。最明显的例子是一个为数据库中的每个表的使用。然而,如果你有兴趣的查询和视图在数据库中,你可以表模块他们。表模块可实例或它可能是一个集合的静态方法。



实例的优点是,它允许您初始化与现有记录集表模块,或者一个查询的结果。然后你可以使用实例操作的行中的记录集。实例也可以使用继承,所以我们可以写一个高峰合同模块包含定期合同附加行为。

表模块可以包括查询工厂方法。替代的是一个表的数据网关(144),但这个缺点是有一个额外的表数据网关(144)在设计类和机制。优点是你可以使用一个单一的表模块对来自不同数据源的数据,因为你使用不同的表数据网关(144)为每个数据源。

当你使用一个表的数据网关(144)应用程序第一次使用表数据入口(144)组装数据在一个记录集(508)。然后创建一个记录集表模块(508)作为一个参数。如果你需要从多个表模块的行为,你可以用相同的记录集(508)。表模块可以进行业务逻辑的记录集(508)通过修改后的记录集(508)用于显示演示和使用表感知部件编辑。部件不能告诉如果记录集直接来自关系数据库或表模块操纵数据的方式。在GUI修改后,该数据集返回确认表模块才能保存到数据库。这一方式的好处是,你可以通过创建一个记录集的测试表模块(508)在存储器中不去数据库。09fig05 GIF。图9.5典型的相互作用在表模块层。





“表”模式中的名称表明您在数据库中每个表有一个表模块。虽然这是真正的第一个近似,但并不是完全真实的。它也有一个常用的视图或其他查询表模块有用。事实上,该表模块并结构不依赖于数据库中表的结构,但在虚拟表的应用感知,包括视图和查询的时候使用它。表模块是基于表的数据,所以使用它的感觉当你使用记录集访问表格数据(508)。


这也使数据结构非常规范的中心,所以你也要你访问数据结构是相当简单的方式。然而,表模块没有给你组织复杂的逻辑对象的全功率。你不能直接实例与实例之间的关系,和多态性不能很好地工作。所以,对于处理复杂的业务逻辑,

一个域模型(116)是一个更好的选择。基本上你有交易的域模型(116)的能力,与基本表数据结构处理复杂的逻辑与表模块的整合更容易。如果在一个域模型对象(116)和数据库比较相似,它可能是更好的使用域模型(116),使用活动记录(160)。

表模块比相结合的域模型(116)和活动记录(160)当其他的应用程序是基于面向普通表的数据结构。这就是为什么你不看在Java环境非常表模块,虽然可能为行集的使用越来越广泛变化。

最著名的情况,我遇到的这个模式是微软COM设计。在COM(和。NET)记录集(508)是在应用程序中数据的主要存储库。记录集可以通过用户界面,在数据感知控件显示信息。微软的ADO库给你一个很好的机制来访问关系数据记录集。在这种情况下表模块可以适应业务逻辑为组织方式的应用,不失各要素对表格数据的方法。例如:用表模块收入确认(三#)时间重新确认收入的例子(112页)我以前在其他领域建模模式,这个时候一个表模块。总的来说,


我们的任务是确认收入的订单时的规则,取决于产品的类型。在这个例子中我们有文字处理器,电子表格和数据库的不同规则,。表模块是基于数据模式的一种,通常是一个关系数据模型(虽然在未来我们可能会看到一个以类似的方式,XML模式)。

在这种情况下我会用图9.6的关系模式。09fig06 。GIF图9.6数据库模式确认收入。类操纵这个数据是几乎相同的形式;有各表一表模块类。在。NET架构一个数据集对象提供了一个在一个数据库结构的存储表示。





这样创建类操作数据集。每个表模块类有一个数据表的一个数据成员,这是。网络系统类对应一个表的数据集内的。这能力读表是常见的所有表模块等都可以出现在一层超类型(475)。
Being translated, please wait..
 
Other languages
The translation tool support: Afrikaans, Albanian, Amharic, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Catalan, Cebuano, Chichewa, Chinese, Chinese Traditional, Corsican, Croatian, Czech, Danish, Detect language, Dutch, English, Esperanto, Estonian, Filipino, Finnish, French, Frisian, Galician, Georgian, German, Greek, Gujarati, Haitian Creole, Hausa, Hawaiian, Hebrew, Hindi, Hmong, Hungarian, Icelandic, Igbo, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Korean, Kurdish (Kurmanji), Kyrgyz, Lao, Latin, Latvian, Lithuanian, Luxembourgish, Macedonian, Malagasy, Malay, Malayalam, Maltese, Maori, Marathi, Mongolian, Myanmar (Burmese), Nepali, Norwegian, Odia (Oriya), Pashto, Persian, Polish, Portuguese, Punjabi, Romanian, Russian, Samoan, Scots Gaelic, Serbian, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenian, Somali, Spanish, Sundanese, Swahili, Swedish, Tajik, Tamil, Tatar, Telugu, Thai, Turkish, Turkmen, Ukrainian, Urdu, Uyghur, Uzbek, Vietnamese, Welsh, Xhosa, Yiddish, Yoruba, Zulu, Language translation.

Copyright ©2025 I Love Translation. All reserved.

E-mail: ilovetranslation@live.com