I'm learning about patterns of j2ee, can anybody tell me what the differences are between table module(domain logic pattern) and table data gateway (data-source pattern)? Thank you
Table Data Gateway is a design pattern in which an object acts as a gateway to a database table. The idea is to separate the responsibility of fetching items from a database from the actual usages of those objects. Users of the gateway are then insulated from changes to the way objects are stored in the database.
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 and Table Data Gateway are both table level patterns, but with a very fundamental difference.
A Table Module is a Domain Logic Pattern in the sense it can contain the BUSINESS LOGIC related to a particular table. A Table Data Gateway is supposed handle Database interface only and is not supposed to contain any Business Logic. Read "database interface" here as "insert/update/delete/read rows from a table".
Please note Martin Fowler's definitions which clearly specify this distinction.
Table Module : A single instance that handles the business logic for all rows in a database table or view.
Table Data Gateway : An object that acts as a Gateway to a database table. One instance handles all the rows in the table. ( "handles" here typically refers to CRUD).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With