Tabular data gateway and architectural scatter of data access objects

Can someone describe the main difference between a table data gateway (TDG) and a data access object (DAO)?

TDG can work with the entire row for this table, but also DAO (DAO can save, delete the specified object, but also perform operations with the whole table)

Hi

+3
source share
1 answer

In my opinion, the main difference is that TDG is a persistance database and DAO is a business / object oriented one.

TDG acts as a facade (grades) in a database table - and is table oriented (change the table and you change the TDG).

DAO , ( , ) - ; DAO -.

TDG , , ( .., , ).

DAO "" , / .

TDG ()

, : :

ContactsTable
--------------------
Id | Name | Ph 
--------------------
01 | Bob  | 192837
02 | Joe  | 564738
03 | Ali  | 483957

, , , . , ( - ). , ( TDG).

- :

Class ContactTableRecord
[
   Id
   Name
   Ph
]

, ; , . , , - ContactTableRecord. , , .

DAO ()

- , , , , , , ..; () . , -, :

Class Customer
[
   Id
   Name
   Ph
   Purchases
   ListAllPurchases()
   SendInvoice()
]

Class Purchase
[
   Id
   ItemDescription
   Customer
   DateOfPurchase
]

- , , . , Dependancy Inversion (DI).

DI - BL DAL; , - :

GetPurchaseDetails() - returns a PurchaseDetails object

PurchaseDetails, BL DAL, , DAO - , . - BL, ( - , DAO ).

// This is our DAO: 
Class PurchaseDetails
[
   CustomerId
   Name
   Ph
   PurchaseId
   ItemDescription
   DateOfPurchase
]

.: Table Data Gateway vs. Data Access Object

+3

Source: https://habr.com/ru/post/1752481/


All Articles