How is the TableData gateway different from the Rowdata Gataway? .. clarification required

I recently read about TableTata Gateway and RowData Gateway. According to the Enterprise Application Architecture Patterns, RDG deals with one record at a time and TDG deals with an entire table. But both of these patterns look very similar, they encapsulate SQL queries and return a single record or many records in the recordset based on the queries we make. I can't figure out when to prefer TDG to RDG.It would be very helpful to clarify the difference with some explanation. According to Martin Fowler, TDG is the same as RDG when it returns a single record. But we can also use RDG for several records! Then why use TDG. Any help would be appreciated. Thanks.

+7
source share
1 answer

Row Data Gateway encapsulates access to a row in the database, while Table Data Gateway encapsulates access at the table level, and it does not seem to me that it is a degenerative form of another.

While the Table Data Gateway finds methods that return RecordSets with the Row Data Gateway, you need a separate Finder class that returns one gateway class for each row.

Do you use and are you using complex decisions related to your choices, what other templates you use.

From his discussions in the "When to Use This" sections of all templates, if you use the Domain Model template, he would prefer to use Active Record . Both of these gateway patterns are reasonable for use in conjunction with Transaction Script .

A table data gateway is simpler, so if it does what you need, it might be the right choice.

You probably would not use both of these patterns in the same application.

+8
source

All Articles