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 ).
Class PurchaseDetails
[
CustomerId
Name
Ph
PurchaseId
ItemDescription
DateOfPurchase
]
.: Table Data Gateway vs. Data Access Object