Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table module and table data gateway patterns

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

like image 841
Xitrum Avatar asked May 20 '11 12:05

Xitrum


People also ask

What is Table Data Gateway Pattern?

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.

What is a table module?

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.


1 Answers

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).

like image 68
Rajesh Chandras Avatar answered Sep 20 '22 10:09

Rajesh Chandras