Page 1 of 1
Alternatives to Active Record
Posted: Wed Aug 09, 2006 11:53 pm
by Luke
I have read a lot about how the active record works great for its purpose, but isn't very efficient. The fact that each record has to be worked with individual hinders performance. Are there better patterns all-around, or does it just depend on the circumstance?
Posted: Thu Aug 10, 2006 12:52 am
by Christopher
I prefer Table Data Gateway because I like a finder style interface. But Active Record with some O/RM thrown in is all the rage since Ruby on Rails.
Fowler catalogs them as
Data Source Architectural Patterns here (second row)
Posted: Sun Aug 13, 2006 12:38 pm
by Ambush Commander
I like Data Mappers, there the easiest to work with (although the hardest to code). Definitely check out Fowler's book.
Posted: Tue Aug 29, 2006 5:31 pm
by Luke
arborint wrote:I prefer Table Data Gateway because I like a finder style interface. But Active Record with some O/RM thrown in is all the rage since Ruby on Rails.
Fowler catalogs them as
Data Source Architectural Patterns here (second row)
what is O/RM?
Posted: Tue Aug 29, 2006 5:37 pm
by Christopher
Posted: Tue Aug 29, 2006 7:37 pm
by wei
If you prefer SQL and be able to utilize more features of your database engine then something like the Ibatis data mapper (avaiable in java and .net, and sort of for php) is ideal.
e.g.
http://ibatis.apache.org/
Posted: Wed Aug 30, 2006 12:36 am
by matthijs
I prefer Table Data Gateway because I like a finder style interface.
Wouldn't a Table Data Gateway often be a good solution for a CRUD-like application in which normalized db tables are used? Like the object User in Fowlers example, or an object Product in a shop. In fact, thinking about it, this pattern is something you'll end up with almost naturally. For example, when you have your db tables users, widgets, transactions and corresponding classes.
Posted: Wed Aug 30, 2006 12:47 am
by Christopher
matthijs wrote:Wouldn't a Table Data Gateway often be a good solution for a CRUD-like application in which normalized db tables are used? Like the object User in Fowlers example, or an object Product in a shop. In fact, thinking about it, this pattern is something you'll end up with almost naturally. For example, when you have your db tables users, widgets, transactions and corresponding classes.
Exactly. I remember when I first learned Table Data Gateway. I had been building similar classes for thing like CRUD and User objects just as you say. Then I saw Table Data Gateway and realized how poor quality and inconsistent my code was. It is a Best Practice pattern for very common code.